This file contains hidden or 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 hidden or 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 hidden or 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
from sklearn.datasets import make_biclusters | |
import numpy as np | |
import matplotlib.pyplot as plt | |
%matplotlib inline | |
def resort_rows_hclust(U): | |
"""Sorts the rows of a matrix by hierarchical clustering | |
Parameters: | |
U (ndarray) : matrix of data |
This file contains hidden or 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 hidden or 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
# The MIT License (MIT) | |
# | |
# Copyright (c) Alex H. Williams | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation | |
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, | |
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the | |
# Software is furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the |
This file contains hidden or 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 numpy.random as npr | |
from functools import reduce | |
# Goal | |
# ---- | |
# Compute (As[0] kron As[1] kron ... As[-1]) @ v | |
# ==== HELPER FUNCTIONS ==== # |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
""" | |
Computing hessian-vector products in tensorflow. | |
For simplicity, we demonstrate the idea on a Poisson regression model. | |
""" | |
import tensorflow as tf | |
import numpy as np | |
from scipy.optimize import minimize |