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.stats leaf.

For mixle.stats distributions carrying a closed-form conjugate prior, the posterior over parameters is available analytically. This runs the distribution’s own conjugate estimator over data to obtain the posterior hyperparameters (read back via the fitted model’s get_prior()), then draws iid parameter samples from that posterior. This is an exact alternative to sample_parameter_posterior().

Supported leaves: Gaussian (NormalGamma posterior, samples (mu, sigma2)), Poisson (Gamma posterior, samples lam), Exponential (Gamma posterior over the rate, samples the scale beta), and Bernoulli, Binomial, and Geometric (Beta posterior, samples p). Binomial draws keep the prototype trial count and support shift fixed.

Parameters:
  • dist (Any) – A mixle.stats distribution; 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