autoemulate.calibration.base#

class BayesianMixin[source]#

Bases: object

Mixin class for Bayesian calibration methods.

logger#
model#
observations#
run_mcmc(warmup_steps=500, num_samples=1000, num_chains=1, initial_params=None, model_kwargs=None, sampler='nuts', **sampler_kwargs)[source]#

Run Markov Chain Monte Carlo (MCMC). Defaults to using the NUTS sampler.

Parameters:
  • warmup_steps (int) – Number of warm up steps to run per chain (i.e., burn-in). These samples are discarded. Defaults to 500.

  • num_samples (int) – Number of samples to draw after warm up. Defaults to 1000.

  • num_chains (int) – Number of parallel chains to run. Defaults to 1.

  • initial_params (dict[str, TensorLike] | None) – Optional dictionary specifiying initial values for each calibration parameter per chain. The tensors must be of length num_chains.

  • model_kwargs (dict | None) – Optional dictionary of keyword arguments to pass to the model.

  • sampler (str) – The MCMC kernel to use, one of “hmc”, “nuts” or “metropolis”.

  • **sampler_kwargs – Additional keyword arguments to pass to the MCMC kernel.

Returns:

The Pyro MCMC object. Methods include summary() and get_samples().

Return type:

MCMC

posterior_predictive(mcmc)[source]#

Return posterior predictive samples.

Parameters:

mcmc (MCMC) – The MCMC object.

Returns:

Tensor of posterior predictive samples [n_mcmc_samples, n_obs, n_outputs].

Return type:

TensorLike

to_arviz(mcmc, posterior_predictive=False)[source]#

Convert MCMC object to Arviz InferenceData object for plotting.

Parameters:
  • mcmc (MCMC) – The MCMC object.

  • posterior_predictive (bool) – Whether to include posterior predictive samples. Defaults to False.

Return type:

az.InferenceData

static to_getdist(data, label, use_weights=True, weight_name='weight')[source]#

Convert Pyro MCMC or ArviZ InferenceData to GetDist MCSamples.

This lightweight helper extends the original implementation to also accept SMC / other results already converted to ArviZ InferenceData. If a weight variable (default: smc_weight) is present in sample_stats it will be used as importance weights.

Parameters:
  • data (MCMC | az.InferenceData) – The Pyro MCMC object or an ArviZ InferenceData object containing posterior samples.

  • label (str) – Label for the MCSamples object.

  • use_weights (bool) – If True and data is an InferenceData with weight_name in sample_stats then those weights are applied. Defaults to True.

  • weight_name (str) – Name of the weight variable inside sample_stats to look up.

Returns:

The GetDist MCSamples object.

Return type:

MCSamples