Skip to content

Priors

Priors on parameters, each a transform of a standard-normal latent ξ. Attach one with Parameter(..., prior=...) or ShareModule.with_priors. See Priors and inference for how they're used, and How it works for the transforms.

spectracles.priors.Prior

Bases: ABC

A prior on a parameter, given as a transform of a standard normal.

transform(ξ) abstractmethod

Map standard-normal latents ξ to parameter values.

inverse(x)

Map parameter values back to latents ξ (only if has_inverse).

sample(key, shape=())

Draw values from the prior.

spectracles.priors.StdNormal dataclass

Bases: Prior

Standard normal, N(0, 1): the value is the latent itself.

spectracles.priors.Normal dataclass

Bases: Prior

Normal with mean mean and standard deviation std.

spectracles.priors.LogNormal dataclass

Bases: Prior

Log-normal with mean mean and standard deviation std of the value itself.

Moment-matched: value = exp(m + s ξ), with s² = log(1 + (std/mean)²) and m = log(mean) - s²/2.

log_moments property

The mean and standard deviation (m, s) of log(value).

spectracles.priors.Laplace dataclass

Bases: Prior

Laplace with location 0 and scale alpha: p(x) = exp(-|x|/alpha) / (2 alpha).

The value is the Laplace quantile function applied to Φ(ξ), computed from log Φ(ξ) for accuracy in the tails.

spectracles.priors.Uniform dataclass

Bases: Prior

Uniform on [low, high]: value = low + (high - low) Φ(ξ).