mixle.inference.mcmc.conjugate module¶
Exact posterior sampling for conjugate mixle.stats leaves.
The sampler uses each supported distribution’s closed-form conjugate update to draw independent parameter samples, providing an analytic alternative to generic MCMC for Gaussian, count, and Bernoulli-family leaves.
- class ConjugateUpdateReceipt(prior_source, prior_status, posterior_status, improper_prior=None, input_mutated=False)[source]
Bases:
objectPrior provenance and propriety status for an analytic posterior update.
- Parameters:
- exception ImproperPosteriorError(receipt)[source]
Bases:
ValueErrorRaised when an explicitly improper prior does not yield a proper posterior.
- Parameters:
receipt (ConjugateUpdateReceipt)
- Return type:
None
- sample_conjugate_posterior(dist, data, draws=1000, seed=None, return_distributions=False, improper_receipt=None)[source]
Draw exact posterior parameter samples for a conjugate
mixle.statsleaf.For
mixle.statsdistributions carrying a closed-form conjugate prior, the posterior over parameters is available analytically. This runs the distribution’s own conjugate estimator overdatato obtain the posterior hyperparameters (read back via the fitted model’sget_prior()), then draws iid parameter samples from that posterior. This is an exact alternative tosample_parameter_posterior().Supported leaves: Gaussian (NormalGamma posterior, samples
(mu, sigma2)), Poisson (Gamma posterior, sampleslam), Exponential (Gamma posterior over the rate, samples the scalebeta), and Bernoulli, Binomial, and Geometric (Beta posterior, samplesp). Binomial draws keep the prototype trial count and support shift fixed.- Parameters:
dist (Any) – A
mixle.statsdistribution; if it carries no conjugate prior, a weak proper family default is attached to an internal copy.data (Any) – Observations for the family.
draws (int) – Number of iid posterior samples.
seed (int | None) – Seed for the RandomState.
return_distributions (bool) – Return rebuilt distributions instead of parameters.
improper_receipt (ImproperPriorReceipt | None) – Explicit acknowledgement for a supported zero-hyperparameter limiting prior. Without this receipt, improper priors are rejected. A still-improper posterior cannot be sampled and raises
ImproperPosteriorErrorcarrying its status receipt.
- Returns:
MCMCResult with iid samples (all accepted, no autocorrelation).
- Return type:
MCMCResult