Repository navigation
Releases: williambdean/distparams
Release list
v0.3.0
Highlights
-
Distribution-level support (
get_support) — every registered distribution now records where its outcomes live, distinct from each parameter's support:- Static supports:
get_support("normal")→(-∞, ∞),get_support("half_normal")→[0, ∞) - Parameter-dependent supports:
get_support("binomial", n=10)→[0, 10] ∩ ℤ— hypergeometric, truncated_normal, von_mises, generalized_pareto, generalized_extreme, and more derive bounds from parameter values - Symbolic resolution: called without values, bounds come back as the parameter names or expressions over them —
get_support("binomial")→[0, n] ∩ ℤ
- Static supports:
-
Downstream build-time checks can reject observations outside the likelihood's support and name the violated bound:
from distparams import get_support support = get_support("gamma") if not support.contains(y): raise ValueError(f"gamma requires observations in {support}, got {y}")
-
All built-in distributions declare supports (vector- and matrix-valued distributions excepted — the exempt list is pinned by the test suite).
Full changelog: v0.2.0...v0.3.0
v0.2.0
Highlights
@parametrized— the decorator formerly known as@distribution. A participle that says what the callable gains: every registered parametrization accepted at call time.distributionremains as a deprecated alias (DeprecationWarning, removed in 0.4.0).- Logp-style value arguments — context parameters (like a logp
x) take positionals in declaration order, sonormal_logp(data, 0, 1),normal_logp(data, mu=0, sigma=1), andbeta_logp(alpha, beta, x)all bind like plain Python. Surplus positionals forward into a declared*args. - Ops backends —
ops=on the decorator and a composable@use_opsscope expression-valued transforms (log-normalscale, discrete-uniform parameters) through backends like polars, so third-party packages can plug in their own ecosystems and arithmetic.
Full changelog: v0.1.0...v0.2.0
v0.1.0
Single source of truth for statistical distribution parameterizations — convert parameters between PyMC, scipy, Stan, R, jStat, TFP, NumPyro, and the stdlib random module. Pure Python, zero dependencies.
Cross-ecosystem conversion
from distparams import convert
convert("gamma", "scipy", "pymc", a=2, scale=3)
# → {"alpha": 2, "beta": 0.333}scipy drop-in that accepts any parametrization
from distparams.stats import norm
norm(mu=0, sigma=1) # canonical names
norm(loc=0, scale=1) # plain scipy
norm(tau=4) # precision → sigma = 0.5
# → a frozen scipy distribution: .pdf, .rvs, .mean, ...stdlib random drop-in, seed-exact
import distparams.random
distparams.random.gamma(alpha=2, beta=1 / 3) # pymc names (beta is the rate)
distparams.random.Random(42).gauss(mu=2, variance=2) # variance → sigmaRegistry-backed parameter inspection
from distparams import get_distribution
sigma = get_distribution("normal").canonical.parameters["sigma"]
sigma.support.contains(0.5) # TrueAlso: 68 distributions, alternative parameterizations (aliases, bijections, derived sets), and a @distribution decorator that resolves ecosystem naming conventions.
Install: pip install distparams