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 jax.numpy as jnp | |
import jax | |
from jax.scipy.stats import norm | |
def generate_observations(H, means, stds): | |
X = ((H == 0) * (means[0] + np.random.randn(*H.shape) * stds[0]) + | |
(H == 1) * (means[1] + np.random.randn(*H.shape) * stds[1])) | |
return X |
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 | |
import jax.numpy as jnp | |
import jax | |
from jax import vmap, jit | |
from jax.scipy.signal import convolve2d | |
def color_image_graph(lx, ly, neigh_list): | |
def first_available(color_list): |
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
''' | |
Sequential Importance Resampling Particle Filter with Jax using jit and | |
lax.scan | |
The model equation for this simple application are: | |
X_{n} = 0.5 * X_{n-1} + 25 * X_{n-1} / (1 + X_{n-1}^2) + 8 * cos(1.2 * n) + U | |
Y_{n} = X_{n}^2 / 20 + V | |
where U~N(0, 10) and V~N(0, 1) | |
''' | |
import matplotlib.pyplot as plt |
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.stats import norm | |
from ctypes import CDLL, c_int, c_double, c_char, c_void_p | |
def generate_observations(H, means, stds): | |
X = ((H == 0) * (means[0] + np.random.randn(*H.shape) * stds[0]) + | |
(H == 1) * (means[1] + np.random.randn(*H.shape) * stds[1])) | |
return X |
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
''' | |
Gaussian Markov Random Field simulation using Fourier properties and base matrices for efficiency | |
References from Gaussian Markov Random Fields: Theory and Applications, Havard Rue and Leonhard Held | |
We treat the 2D case, with 0 mean, stationary variance and exponential correlation function | |
''' | |
import matplotlib.pyplot as plt | |
import numpy as np | |
from scipy.fftpack import fft2, ifft2 |
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
''' | |
Equivalence between a gradient ascent over the Expectation Maximization | |
quantity Q and a gradient ascent over the model likelihood in the case of | |
training an Hidden Markov Chain with Gaussian Independent Noise | |
''' | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import jax.numpy as jnp | |
import jax | |
from jax.scipy.stats import norm |