autoemulate.calibration.bayes#

class BayesianCalibration(emulator, parameter_range, observations, observation_noise=0.1, calibration_params=None, device=None, log_level='progress_bar')[source]#

Bases: TorchDeviceMixin

Bayesian calibration using Markov Chain Monte Carlo (MCMC).

Bayesian calibration estimates the probability distribution over input parameters given observed data, providing uncertainty estimates.

model(predict=False)[source]#

Pyro model.

Parameters:

predict (bool) – Whether to run the model with existing samples to generate posterior predictive distribution. Used with pyro.infer.Predictive.

run_mcmc(warmup_steps=500, num_samples=1000, num_chains=1, initial_params=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.

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

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