Skip to content

Releases: williambdean/distparams

v0.3.0

Choose a tag to compare

@williambdean williambdean released this 09 Sep 12:06
8d4bae2

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] ∩ ℤ
  • 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

Choose a tag to compare

@williambdean williambdean released this 07 Sep 10:34
3c72963

Highlights

  • @parametrized — the decorator formerly known as @distribution. A participle that says what the callable gains: every registered parametrization accepted at call time. distribution remains 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, so normal_logp(data, 0, 1), normal_logp(data, mu=0, sigma=1), and beta_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_ops scope expression-valued transforms (log-normal scale, 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

Choose a tag to compare

@williambdean williambdean released this 05 Sep 12:49
3a021d9

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 → sigma

Registry-backed parameter inspection

from distparams import get_distribution

sigma = get_distribution("normal").canonical.parameters["sigma"]
sigma.support.contains(0.5)  # True

Also: 68 distributions, alternative parameterizations (aliases, bijections, derived sets), and a @distribution decorator that resolves ecosystem naming conventions.

Install: pip install distparams