mixle.inference.mcmc.conjugate module¶
Exact conjugate posterior sampling for closed-form mixle.stats leaves.
- sample_conjugate_posterior(dist, data, draws=1000, seed=None, return_distributions=False)[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 non-informative default for the family is attached automatically.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.
- Returns:
MCMCResult with iid samples (all accepted, no autocorrelation).
- Return type:
MCMCResult