Skip to content

API reference

Technical description of the machinery. The generated docstrings live on two pages, Continuous and Discrete; the input types, dtypes, and error contracts are in Parameters and contracts.

For worked examples, see the tutorial and the How-to guides.

Catalogue

Distribution Kind Parameters scipy equivalent
Beta(a, b) continuous a > 0, b > 0 beta(a, b)
Exponential(rate) continuous rate > 0 expon(scale=1 / rate)
LogNormal(mu, sigma) continuous sigma > 0 lognorm(s=sigma, scale=exp(mu))
Normal(mu, sigma) continuous sigma > 0 norm(loc=mu, scale=sigma)
Uniform(min, max) continuous max > min uniform(loc=min, scale=max - min)
Bernoulli(p) discrete 0 <= p <= 1 bernoulli(p)
Binomial(n, p) discrete n >= 0, 0 <= p <= 1 binom(n, p)

Each class names its parameters after the distribution's conventional parameters. Normal and LogNormal default to mu=0.0, sigma=1.0; the others have no defaults. Parameter values are validated at evaluation, not at construction.

Method surface

Every distribution exposes the same surface, defined on the base classes. Value-keyed methods take a scalar, a column name (str), or a pl.Expr; argument-free statistics take none. All return a pl.Expr.

Method Continuous Discrete Meaning
pdf(x) yes no probability density
log_pdf(x) yes no log density
pmf(x) no yes probability mass
log_pmf(x) no yes log mass
cdf(x) yes yes P(X <= x)
sf(x) yes yes survival, P(X > x), accurate in the upper tail
ppf(q) yes yes inverse cdf, q in [0, 1]
isf(q) yes yes inverse survival, ppf(1 - q)
log_cdf(x) yes yes log cdf
log_sf(x) yes yes log survival
mean() yes yes E[X]
variance() / std() yes yes variance and its square root
median() yes yes ppf(0.5), or a closed form when available
entropy() yes yes differential / Shannon entropy, in nats
sample(seed=None) yes yes one variate per row
samples(size, seed=None) yes yes a width-size Array per row

Where a more accurate closed form is available (a native sf, ln_pdf, or a stable log_sf), a distribution binds it; otherwise the composing defaults apply (sf = 1 - cdf, log_pdf = pdf().log(), median = ppf(0.5)).

Argument-free statistics return one value per row of parameters: with column-valued parameters, mean() yields the mean of a different distribution on every row.

Compatibility

Dimension Values
Python 3.10 to 3.14 (per requires-python), single abi3 wheel
Polars >=1.15 (the pyo3-polars ABI floor)
OS wheels for Linux x86_64/aarch64, macOS arm64/x86_64, Windows x86_64
Runtime dependencies polars only