This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CC = gcc #gcc-4.2 | |
MATLABDIR=/Applications/MATLAB_R2011a.app | |
INCLUDES=-I$(MATLABDIR)/extern/include | |
LDIRS= -L$(MATLABDIR)/bin/maci64 | |
EXE_TARGETS = segm_overlap_mex.mexa64 segm_intersection_mex.mexa64 | |
all: $(EXE_TARGETS) | |
overlap.o: overlap.c | |
$(CC) -D__MAIN__ -O3 -fPIC -c $(INCLUDES) -fopenmp -o overlap.o overlap.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inversions :: (Ord a) => [a] -> Int | |
inversions list = let (n,_) = inversions' list in n | |
inversions' :: (Ord a) => [a] -> (Int,[a]) | |
inversions' [] = (0, []) | |
inversions' [a] = (0, [a]) | |
inversions' list = | |
let half = (length list) `div` 2 | |
(na, a) = inversions' (take half list) | |
(nb, b) = inversions' (drop half list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Using built-in specs. | |
Target: i686-apple-darwin10 | |
Configured with: /var/tmp/gcc/gcc-5666.3~6/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1 | |
Thread model: posix | |
gcc version 4.2.1 (Apple Inc. build 5666) (dot 3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
==> Downloading http://ftpmirror.gnu.org/octave/octave-3.6.3.tar.bz2 | |
Already downloaded: /Users/carsten/Library/Caches/Homebrew/octave-3.6.3.tar.bz2 | |
/usr/bin/tar xf /Users/carsten/Library/Caches/Homebrew/octave-3.6.3.tar.bz2 | |
==> Using Homebrew-provided fortran compiler. | |
This may be changed by setting the FC environment variable. | |
==> ./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/octave/3.6.3 --with-blas=-ldotwrp -Wl,-framework -Wl,Accelerate --with-umfpack=-lumfpack -lsuitesparseconfig | |
./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/octave/3.6.3 --with-blas=-ldotwrp -Wl,-framework -Wl,Accelerate --with-umfpack=-lumfpack -lsuitesparseconfig | |
checking for a BSD-compatible install... /usr/bin/install -c | |
checking whether build environment is sane... yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cvxpy | |
import numpy as np | |
if __name__ == "__main__": | |
#The histogram data, 250 histograms with 3 bins | |
D = cvxpy.parameter(250,3,name='D') | |
D.value = cvxpy.matrix(np.random.randint(0,100,(250,3))) | |
#The weights, one for each histogram |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def weighted_sample(weights, sample_size): | |
""" | |
Returns a weighted sample without replacement. Note: weights.dtype should be float for speed, see: http://sociograph.blogspot.nl/2011/12/gotcha-with-numpys-searchsorted.html | |
""" | |
totals = np.cumsum(weights) | |
sample = [] | |
for i in xrange(sample_size): | |
rnd = random.random() * totals[-1] | |
idx = np.searchsorted(totals,rnd,'right') | |
sample.append(idx) |