mixle.inference.priors moduleΒΆ

Prior specifications for declaration-backed MAP fitting.

The classes in this module are lightweight, serializable descriptions of common priors. They intentionally do not depend on NumPy, Torch, or a concrete compute engine; fitting code turns them into backend tensors at objective time.

class BetaPrior(alpha, beta, parameter=None)[source]

Bases: object

Beta prior for unit-interval parameters.

Parameters:
alpha: float
beta: float
parameter: str | None = None
as_dict()[source]

Return the normalized Beta prior payload.

Return type:

dict

class ConditionalPrior(conditions, default=None, given=None)[source]

Bases: object

Per-key, default, and given priors for a ConditionalDistribution.

Parameters:
conditions: Mapping[Any, Any]
default: Any | None = None
given: Any | None = None
as_dict()[source]

Return keyed/default/given priors as a plain payload.

Return type:

dict

class CompositePrior(children)[source]

Bases: object

Child priors for a CompositeDistribution.

Parameters:

children (Sequence[Any])

children: Sequence[Any]
as_dict()[source]

Return child priors as a plain composite-prior payload.

Return type:

dict

class DirichletPrior(alpha)[source]

Bases: object

Dirichlet prior for simplex-valued parameters.

Parameters:

alpha (Any)

alpha: Any
as_dict()[source]

Return the normalized Dirichlet prior payload.

Return type:

dict

class GammaPrior(shape, rate, parameter=None)[source]

Bases: object

Gamma prior for positive scalar parameters or ordered-bound deltas.

Parameters:
shape: float
rate: float
parameter: str | None = None
as_dict()[source]

Return the normalized Gamma prior payload.

Return type:

dict

class MarkovChainPrior(initial=None, transitions=None, length=None)[source]

Bases: object

Initial, transition-row, and length priors for MarkovChainDistribution.

Parameters:
initial: Any | None = None
transitions: Mapping[Any, Any] | None = None
length: Any | None = None
as_dict()[source]

Return initial, transition, and length priors as a plain payload.

Return type:

dict

class MixturePrior(components=(), weights=None)[source]

Bases: object

Component and weight priors for a MixtureDistribution.

Parameters:
components: Sequence[Any] = ()
weights: Any | None = None
as_dict()[source]

Return component and weight priors as a plain payload.

Return type:

dict

class NormalGammaPrior(mu0=0.0, kappa=0.0, alpha=1.0, beta=0.0)[source]

Bases: object

Normal-Gamma prior for Gaussian mu and precision tau.

The density is proportional to tau ** (alpha - 1) exp(-beta tau) sqrt(tau) exp(-0.5 * kappa * tau * (mu - mu0) ** 2). Normalizing constants are omitted because MAP fitting only needs objective differences.

Parameters:
mu0: float = 0.0
kappa: float = 0.0
alpha: float = 1.0
beta: float = 0.0
as_dict()[source]

Return the normalized prior payload consumed by MAP fitters.

Return type:

dict

class OptionalPrior(observed=None, missing=None)[source]

Bases: object

Observed-child and missing-probability priors for OptionalDistribution.

Parameters:
  • observed (Any | None)

  • missing (Any | None)

observed: Any | None = None
missing: Any | None = None
as_dict()[source]

Return observed-child and missingness priors as a plain payload.

Return type:

dict

class RecordPrior(fields)[source]

Bases: object

Field priors for a named RecordDistribution.

Parameters:

fields (Mapping[Any, Any])

fields: Mapping[Any, Any]
as_dict()[source]

Return field priors as a plain record-prior payload.

Return type:

dict

as_prior_dict(prior)[source]

Return a plain-Python representation of a prior specification.

Parameters:

prior (Any)

Return type:

Any

beta(alpha, beta, parameter=None)[source]

Create a Beta prior for a unit-interval parameter.

Parameters:
Return type:

BetaPrior

conditional(conditions, default=None, given=None)[source]

Create a Conditional prior over keyed/default/given child priors.

Parameters:
Return type:

ConditionalPrior

composite(children)[source]

Create a Composite prior from child prior specifications.

Parameters:

children (Sequence[Any])

Return type:

CompositePrior

dirichlet(alpha)[source]

Create a Dirichlet prior for simplex-valued parameters.

Parameters:

alpha (Any)

Return type:

DirichletPrior

gamma(shape, rate, parameter=None)[source]

Create a Gamma prior for a positive parameter.

Parameters:
Return type:

GammaPrior

markov_chain(initial=None, transitions=None, length=None)[source]

Create a Markov-chain prior over initial, transition, and length terms.

Parameters:
Return type:

MarkovChainPrior

mixture(components=(), weights=None)[source]

Create a Mixture prior over component and weight priors.

Parameters:
Return type:

MixturePrior

normal_gamma(mu0=0.0, kappa=0.0, alpha=1.0, beta=0.0)[source]

Create a Normal-Gamma prior for Gaussian mean/precision parameters.

Parameters:
Return type:

NormalGammaPrior

optional(observed=None, missing=None)[source]

Create an Optional prior over observed child and missingness terms.

Parameters:
  • observed (Any | None)

  • missing (Any | None)

Return type:

OptionalPrior

record(fields)[source]

Create a Record prior from field-name prior specifications.

Parameters:

fields (Mapping[Any, Any])

Return type:

RecordPrior