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 bandpass(x, lowcut, highcut, fs, order=5, axis=-1, kind='butter'): | |
""" | |
Parameters | |
---------- | |
x : ndarray | |
1d time series data | |
lowcut : float | |
Defines lower frequency cutoff (e.g. in Hz) | |
highcut : float | |
Defines upper frequency cutoff (e.g. in Hz) |
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 tensorflow as tf | |
# N, size of matrix. R, rank of data | |
N = 100 | |
R = 5 | |
# generate data | |
W_true = np.random.randn(N,R) | |
C_true = np.random.randn(R,N) |
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 scipy.linalg import solve_circulant, circulant | |
from numpy.testing import assert_array_almost_equal | |
import numba | |
@numba.jit(nopython=True, cache=True) | |
def rojo_method(c, a, f, x, z): | |
""" | |
Solves symmetric, tridiagonal circulant system, assuming diagonal |
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 sklearn.utils.extmath import randomized_svd | |
def partial_whiten(X, alpha, eigval_tol=1e-7): | |
""" | |
Return regularized whitening transform for a matrix X. | |
Parameters | |
---------- |
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
# Majority of credit goes to Chris Holdgraf, @choldgraf, and this StackOverflow | |
# post: http://stackoverflow.com/questions/5320205/matplotlib-text-dimensions | |
import pylab as plt | |
import numpy as np | |
def plot_equation(eq, fontsize=50, outfile=None, padding=0.1, **kwargs): | |
"""Plot an equation as a matplotlib figure. | |
Parameters | |
---------- |
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 PyPlot | |
using Distributions | |
function credible_interval(D::UnivariateDistribution; c=0.95, nx=1000) | |
# Discretize over the support | |
r = support(D) | |
lb,ub = r.lb,r.ub | |
# Histogram approximation of area under pdf | |
x = linspace(lb,ub,nx) |
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 scipy.io as spio | |
import numpy as np | |
def loadmat(filename): | |
''' | |
this function should be called instead of direct spio.loadmat | |
as it cures the problem of not properly recovering python dictionaries | |
from mat files. It calls the function check keys to cure all entries | |
which are still mat-objects | |
''' |
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
""" | |
References: | |
- B. Plateau, On the stochastic structure of parallelism and synchronization models for distributed algorithms. | |
Perform. Eval. Rev., 13 (1985), pp. 147–154. | |
- Dayar, T., & Orhan, M. C. (2015). On vector-Kronecker product multiplication with rectangular factors. | |
SIAM Journal on Scientific Computing, 37(5), S526-S543. | |
""" |
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
""" | |
A simple implementation of a permutation test among two | |
independent samples. | |
""" | |
import numpy as np | |
from sklearn.utils.validation import check_random_state | |
from more_itertools import distinct_permutations | |
from scipy.stats import percentileofscore | |
from math import factorial |
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 tensorflow as tf | |
# N, size of matrix. R, rank of data | |
N = 100 | |
R = 5 | |
# generate data | |
W_true = np.random.randn(N,R) | |
C_true = np.random.randn(R,N) |