Skip to content

Instantly share code, notes, and snippets.

View slinderman's full-sized avatar

Scott Linderman slinderman

View GitHub Profile
@slinderman
slinderman / jax_minimize_wrapper.py
Last active May 20, 2024 07:29
A simple wrapper for scipy.optimize.minimize using JAX. UPDATE: This is obsolete now that `jax.scipy.optimize.minimize` is exists!
"""
A collection of helper functions for optimization with JAX.
UPDATE: This is obsolete now that `jax.scipy.optimize.minimize` is exists!
"""
import numpy as onp
import scipy.optimize
from jax import grad, jit
from jax.tree_util import tree_flatten, tree_unflatten
from jax.flatten_util import ravel_pytree
@slinderman
slinderman / bar_demo.ipynb
Created November 16, 2017 19:25
Bars for Matt
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@slinderman
slinderman / sample_predictions.py
Created January 10, 2017 15:28
Sample predictions test
import numpy as np
import matplotlib.pyplot as plt
from pylds.models import DefaultLDS
inputs = \
np.array([[ 0. , 0. ],
[ 2.72785283, 7.53608657],
[ 0. , 7.23201033],
[ 2.0261219 , 7.07866193],
[ 2.42989525, 7.67644583],
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@slinderman
slinderman / hmm.py
Created October 18, 2016 15:27
Sticky vs Standard HMM with smart initialization
from __future__ import division
from builtins import range
import numpy as np
np.seterr(divide='ignore') # these warnings are usually harmless for this code
np.random.seed(0)
from matplotlib import pyplot as plt
import matplotlib
import os
matplotlib.rcParams['font.size'] = 8
@slinderman
slinderman / lorenz.ipynb
Last active October 24, 2017 22:17
Using an switching linear model to approximate a nonlinear dynamical system
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import numpy as np
import matplotlib.pyplot as plt
from hips.plotting.layout import create_figure, create_axis_at_location
from hips.plotting.colormaps import gradient_cmap
import seaborn as sns
color_names = ["windows blue",
"amber",
"crimson",
# Simple demo showing weird marginal likelihood estimates
# for GP classification when using EP inference.
import numpy as np
np.random.seed(0)
import matplotlib.pyplot as plt
import GPy
from GPy.kern import RBF
# Model parameters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@slinderman
slinderman / hmm.py
Last active December 23, 2015 18:57
from __future__ import division
import numpy as np
np.seterr(divide='ignore') # these warnings are usually harmless for this code
from matplotlib import pyplot as plt
import matplotlib
import os
matplotlib.rcParams['font.size'] = 8
import pyhsmm
from pyhsmm.util.text import progprint_xrange