Alex Williams ahwillia
- Palo Alto, CA
- Sign in to view email
- http://alexhwilliams.info
View kron_vec_product.py
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 ==== # |
View kronshuff.py
""" | |
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. | |
""" |
View rojo.py
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 |
View bandpass.py
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) |
View poiss_tf.py
""" | |
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 |
View poiss_reg.py
""" | |
A simple implementation of Poisson regression. | |
""" | |
import numpy as np | |
from scipy.optimize import minimize | |
n = 1000 # number of datapoints | |
p = 5 # number of features |
View copy_task.py
# coding: utf-8 | |
# In[1]: | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import scipy.linalg as sci | |
# In[2]: |
View bcd_cnmf.py
import numpy as np | |
from tqdm import trange | |
import matplotlib.pyplot as plt | |
# TODO: subclass np.ndarray? | |
class ShiftMatrix(object): | |
""" | |
Thin wrapper around a numpy matrix to support shifting along the second | |
axis and padding with zeros. |
View cv.py
import numpy as np | |
from numpy.random import randn, rand | |
from scipy.optimize import minimize | |
import matplotlib.pyplot as plt | |
from nnls import nnlsm_blockpivot as nnlstsq | |
import itertools | |
from scipy.spatial.distance import cdist | |
def censored_lstsq(A, B, M): | |
"""Solves least squares problem with missing data in B |
View tsp.py
def reverse_segment(path, n1, n2): | |
"""Reverse the nodes between n1 and n2. | |
""" | |
q = path.copy() | |
if n2 > n1: | |
q[n1:(n2+1)] = path[n1:(n2+1)][::-1] | |
return q | |
else: | |
seg = np.hstack((path[n1:], path[:(n2+1)]))[::-1] | |
brk = len(q) - n1 |
NewerOlder