superstats.prior.prior#
Elementary prior distributions.
Classes
|
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:
objectSimple generative prior distribution.
- Parameters:
- dist{“normal”, “uniform”, “beta”, “halfnormal”, “dirichlet”, “logistic”}
Distribution type.
- loc
float,optional, default: 0.0 Mean for normal.
- scale
float,optional, default: 1.0 Standard deviation for normal / halfnormal.
- low
float,optional, default: 0.0 Lower bound for uniform.
- high
float,optional, default: 1.0 Upper bound for uniform.
- a
float,optional, default: 1.0 Alpha (first shape parameter) for beta.
- b
float,optional, default: 1.0 Beta (second shape parameter) for beta.
- alphasequence
offloatorNone,optional, default:None Concentration parameters for dirichlet. Required when dist=”dirichlet” (e.g. [1, 1, 1] for a uniform simplex over 3 categories).
- scale_factor
float,optional, default: 1.0 Multiplicative scaling applied to the drawn samples: scale_factor * samples + shift.
- shift
float,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_size
int Number of samples to draw.
- batch_size
- Returns:
- samples
np.ndarray-shape(batch_size,),or(batch_size,K) for dirichlet where K is the number of categories
- samples
- Raises:
ValueErrorIf 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: