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 numpy as np | |
import matplotlib.pyplot as plt | |
pops = np.array([39538223, | |
29145505, | |
21538187, | |
20201249, | |
13011844, | |
12812508, | |
11799448, |
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
# All sizes are in fraction of the figure size | |
figsize = (6, 7.5) | |
f = plt.figure(figsize=figsize) | |
# borders | |
top_edge = .03 | |
bot_edge = .055 | |
l_edge = .15 | |
r_edge = .01 |
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 numpy as np | |
import theano | |
import theano.tensor as T | |
def numpy_version(prob, cases): | |
return np.matmul(prob.transpose(2,0,1), cases.T).T | |
last_dim = 50 | |
dot_dim = 1000 | |
other_dim = 1000 |
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 numpy as np | |
from numpy.fft import fft as nfft, ifft as nifft | |
from accelerate.mkl.fftpack import fft as mfft, ifft as mifft | |
from pyfftw.interfaces.numpy_fft import fft as wfft, ifft as wifft | |
import matplotlib.pyplot as plt | |
import time | |
start = 3 | |
end = 5 | |
diff = 4*(end-start)+1 |
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
#!/usr/bin/env python | |
import argparse, time, os, subprocess | |
import numpy as np | |
import theano | |
from theano.tensor.nnet.corr import (CorrMM, CorrMM_gradInputs, | |
CorrMM_gradWeights) | |
from theano.compat.python2x import OrderedDict | |
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
#this is the constraint that makes Pyhy[i,i] > Pyhy[i,j] | |
def con4(inputArray): | |
Pyhy_i = inputArray.reshape(n,n) | |
# get diagonal vector (Pyhy[i,i]) | |
Pyhy_diag = np.diag(Pyhy_i) | |
# get max of each row | |
Pyhy_max = Pyhy.max(axis=1) | |
# we want the difference to be positive or zero | |
diff = Pyhy_diag - Pyhy_max | |
# we want all of the differences to be positive, so we can just return the most negative one |
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 corrcoef(X, Y): | |
""" | |
Return Pearson correlation coefficients between 1 and n variables. | |
Parameters | |
---------- | |
X : (1 x dim) matrix, single voxel | |
Y : (n x dim) matrix, other voxels | |
""" | |
X_no_mean = X - X.mean(keepdims=True) |
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 log_multivariate_normal_density(X, means, covars, min_covar=1.e-7): | |
"""Log probability for full covariance matrices. """ | |
if hasattr(linalg, 'solve_triangular'): | |
# only in scipy since 0.9 | |
solve_triangular = linalg.solve_triangular | |
else: | |
# slower, but works | |
solve_triangular = linalg.solve | |
n_samples, n_dim = X.shape | |
nmix = len(means) |