hippylib2muq.mcmc package

Submodules

hippylib2muq.mcmc.diagnostics module

This module provides a convergence diagnostic for samples drawn from MCMC methods.

class hippylib2muq.mcmc.diagnostics.MultPSRF(ndof, nsamps, nchain)

Bases: object

Computing the Multivariate Potential Scale Reduction Factor

This class is to compute the Multivariate Potential Scale Reduction Factor (MPSRF) described in [Brooks1998]. Note that MPSRF is the square-root version, i.e., \(\hat{R}^p\) where \(\hat{R}^p\) is defined by Equation (4.1) in [Brooks1998].

Brooks1998(1,2,3)

Brooks and Gelman, 1998, General Methods for Monitoring Convergence of Iterative Simulations.

compute_mpsrf()

Compute MPSRF.

print_result()

Print the description and the result of MCMC chains and its diagnostic.

update_W(samps)

Update the within-sequence varance matrix W for a chain samps.

Parameters

samps (numpy:ndarray) – a sequence of samples generated

class hippylib2muq.mcmc.diagnostics.PSRF(nsamps, nchain, calEss=False, max_lag=None)

Bases: object

Computing the Potential Scale Reduction Factor and the effective sample size

This class is to compute the Potential Scale Reduction Factor (PSRF) and the effective sample size (ESS) as described in [Brooks1998] and [Gelman2014]. Note that PSRF is the square-root version of \(\hat{R}\) where \(\hat{R}\) is defined by Equation (1.1) defined in [Brooks1998].

Gelman2014

Gelman et al., 2014, Bayesian Data Analysis, pp 286-287.

compute_PsrfEss(plot_acorr=False, write_acorr=False, fname=None)

Compute PSRF and ESS

Parameters
  • plot_acorr (bool) – if True, plot the autocorrelation function

  • write_acorr (bool) – if True, write the autocorrelation function to a file

  • fname (string) – file name for the autocorrelation function result

print_result()

Print the description and the result of MCMC chains and its diagnostic.

update_W(sample)

Update the within-sequence varance W for a chain samps.

Parameters

samps (numpy:ndarray) – a sequence of samples generated

hippylib2muq.mcmc.qoi module

This module contains some functions related to the quantity of interest.

hippylib2muq.mcmc.qoi.cal_qoiTracer(pde, qoi, muq_samps)

This function is for tracing the quantity of interest.

Parameters
  • pde (hippylib:PDEProblem) – a hippylib:PDEProblem instance

  • qoi – the quantity of interest; it should contain the member function named as eval which evaluates the value of qoi

  • muq_samps – samples generated from muq sampler

hippylib2muq.mcmc.qoi.track_qoiTracer(pde, qoi, method_list, max_lag=None)

This function computes the autocorrelation function and the effective sample size of the quantity of interest.

Parameters
  • pde (hippylib:PDEProblem) – a hippylib:PDEProblem instance

  • qoi – the quantity of interest; it should contain the member function

  • method_list (dictionary) – a dictionary containing MCMC methods descriptions with samples generated from muq sampler

  • max_lag (int) – maximum of time lag for computing the autocorrelation function

Module contents