normix#
normix is a JAX package for Generalized
Hyperbolic distributions and their relatives, implemented as exponential
families. It is built on Equinox with
float64 precision throughout. Log-densities, moments, and the JAX
log-partition triad are JIT-compiled and differentiable.
log_prob takes one observation.
vmap applies it to a batch.
The supported surface is the capability matrix.
import jax
jax.config.update("jax_enable_x64", True)
import jax.numpy as jnp
from normix import GeneralizedHyperbolic
# Fit a Generalized Hyperbolic distribution to data via EM
key = jax.random.PRNGKey(0)
X = jax.random.normal(key, (1000, 3))
model = GeneralizedHyperbolic.default_init(X)
result = model.fit(X, max_iter=100)
# Evaluate the log-density (batched via vmap)
log_p = jax.vmap(result.model.log_prob)(X)
Key features#
Exponential-family structure — classical parameters and natural \(\theta\) convert exactly.
from_expectationinverts \(\eta = \nabla\psi(\theta)\) in closed form or to a solver tolerance.The full GH family — Gamma, Inverse Gamma, Inverse Gaussian, GIG, Variance Gamma, Normal-Inverse Gamma, Normal-Inverse Gaussian, and Generalized Hyperbolic, plus univariate and factor variants.
EM fitting — batch and incremental EM. Bessel values come from the
log_kvkernel in JAX or NumPy. SciPy supplies the CPU optimizers. CPU Gamma usesscipy.specialdigamma and polygamma.scipy.special.kveis a test oracle.Closed-form divergences — squared Hellinger and KL with no Monte Carlo.
Finance toolkit — portfolio projection and differentiable CVaR.
Immutable — all distributions are
equinox.Modulepytrees.
Where to start#
Install, a 30-second quickstart, and a guided first fit.
One page per distribution — density picture, parametrizations, ten-line recipe.
Executable end-to-end tracks: core, distributions, EM, stats, finance.
Concepts behind the API — exponential families, EM, divergences, finance.
Formal derivations for the GH family, EM, and portfolio mathematics.
Autodoc for every public module — distributions, mixtures, fitting, finance.
Working notes: subordinator-tracking portfolios on the S&P 500.
ASV trend dashboard — Bessel, GIG, EM, compile; CPU and CUDA.