Skip to content

Instantly share code, notes, and snippets.

View AFg6K7h4fhy2's full-sized avatar

upx3 (CFA) AFg6K7h4fhy2

View GitHub Profile
@AFg6K7h4fhy2
AFg6K7h4fhy2 / diffrax_SEIR_simulation.md
Last active May 21, 2024 17:43
An SEIR model for simulation, implemented in diffrax, with parameters geared towards influenza.

Consider the following compartmental SEIR model (without births or deaths) for influenza:

$$ \begin{aligned} S' &= -\beta S I \\ E' &= \beta S I - \alpha E\\ I' &= \alpha E - \gamma I \\ R' &= \gamma I \end{aligned} $$

@AFg6K7h4fhy2
AFg6K7h4fhy2 / diffrax_SLIAR_1957_simulation.md
Created May 21, 2024 17:18
An SLIAR model for the 1957 influenza pandemic implemented using diffrax.

Consider the following compartmental SLIAR model (with births or deaths) for influenza during the 1957 pandemic:

$$ \begin{aligned} S' &= -\beta S (I + \delta A)\ L' &= \beta S (I + \delta A) - \kappa L\ I' &= p \kappa L - \alpha I \ A' &= (1 - p) \kappa L - \eta A\ R' &= \alpha I + \eta A \end{aligned}

@AFg6K7h4fhy2
AFg6K7h4fhy2 / imperative_numpyro_example.md
Last active May 21, 2024 17:52
Example for imperative use of Numpyro to retrieve posterior samples and simulate data.

NOTE: This is nearly the same description as given in AFg6K7h4fhy2/declarative_numpyro_example.py

Given observations $$x_i \sim \mathcal{N}(\mu=0, \sigma=3) \quad i=1,2,\dotsc,500$$ and priors $\mu \sim \mathcal{U}(0,3)$ and $\sigma \sim \mathcal{U}(0, 9)$, produce 1000 samples from the posterior distribution.

The output from inferring parameter values from observations:

@AFg6K7h4fhy2
AFg6K7h4fhy2 / declarative_numpyro_example.md
Last active May 18, 2024 05:26
Example for declarative use of Numpyro to retrieve posterior samples and simulate data.

Given observations $$x_i \sim \mathcal{N}(\mu=0, \sigma=3) \quad i=1,2,\dotsc,500$$ and priors $\mu \sim \mathcal{U}(0,3)$ and $\sigma \sim \mathcal{U}(0, 9)$, produce 1000 samples from the posterior distribution and also simulate 1000 samples from the priors.

"""
A short example guide on using numpyro declaratively, i.e.
with out specifying defining a log posterior explicitly.
"""

import jax.random as jr
import numpyro as npro