superstats.prior.prior#

Elementary prior distributions.

Classes

Prior(dist[, loc, scale, low, high, a, b, ...])

Simple generative prior distribution.

class superstats.prior.prior.Prior(dist, loc=0.0, scale=1.0, low=0.0, high=1.0, a=1.0, b=1.0, alpha=None, scale_factor=1.0, shift=0.0)[source]#

Bases: object

Simple generative prior distribution.

Parameters:
dist{“normal”, “uniform”, “beta”, “halfnormal”, “dirichlet”, “logistic”}

Distribution type.

locfloat, optional, default: 0.0

Mean for normal.

scalefloat, optional, default: 1.0

Standard deviation for normal / halfnormal.

lowfloat, optional, default: 0.0

Lower bound for uniform.

highfloat, optional, default: 1.0

Upper bound for uniform.

afloat, optional, default: 1.0

Alpha (first shape parameter) for beta.

bfloat, optional, default: 1.0

Beta (second shape parameter) for beta.

alphasequence of float or None, optional, default: None

Concentration parameters for dirichlet. Required when dist=”dirichlet” (e.g. [1, 1, 1] for a uniform simplex over 3 categories).

scale_factorfloat, optional, default: 1.0

Multiplicative scaling applied to the drawn samples: scale_factor * samples + shift.

shiftfloat, optional, default: 0.0

Additive offset applied to the drawn samples: scale_factor * samples + shift.

Parameters:
sample(batch_size)[source]#

Draw samples from the prior.

Samples are transformed as scale_factor * samples + shift before being returned.

Parameters:
batch_sizeint

Number of samples to draw.

Returns:
samplesnp.ndarray - shape (batch_size,), or (batch_size, K)

for dirichlet where K is the number of categories

Raises:
ValueError

If dist=”dirichlet” and alpha is None or not a vector-like sequence, or if dist is not one of the supported distributions.

Parameters:

batch_size (int)

Return type:

ndarray