pybop.samplers.mcmc_summary#

Classes#

Module Contents#

class pybop.samplers.mcmc_summary.PosteriorSummary(chains: numpy.ndarray, significant_digits: int = 4)[source]#
_autocorrelate_negative(autocorrelation)[source]#

Returns the index of the first negative entry in autocorrelation, or len(autocorrelation) if a negative entry is not found.

_calculate_statistics(fun, attr_name, *args, **kwargs)[source]#

Calculate statistics from callable fun.

autocorrelation(x: numpy.ndarray) numpy.ndarray[source]#

Computes the autocorrelation (Pearson correlation coefficient) of a numpy array representing samples.

effective_sample_size(mixed_chains=False)[source]#

Computes the effective sample size (ESS) for each parameter in each chain.

Parameters:

mixed_chains (bool, optional) – If True, the ESS is computed for all samplers mixed into a single chain. Defaults to False.

Returns:

A list of effective sample sizes for each parameter in each chain, or for the mixed chain if mixed_chains is True.

Return type:

list

Raises:

ValueError – If there are fewer than two samples in the data.

get_summary_statistics()[source]#

Calculate summary statistics for the posterior samples.

Returns: dict: Summary statistics including mean, median, standard deviation, and 95% credible interval.

plot_chains(**kwargs)[source]#

Plot posterior distributions for each chain.

plot_posterior(**kwargs)[source]#

Plot the summed posterior distribution across chains.

plot_trace(**kwargs)[source]#

Plot trace plots for the posterior samples.

rhat()[source]#

Computes the Gelman-Rubin statistic which diagnoses MCMC convergence. For well-mixed and stationary chains R-hat will be close to one, otherwise it is higher.

signif(x, p: int)[source]#

Rounds array x to p significant digits.

summary_table()[source]#

Display summary statistics in a table.

all_samples[source]#
chains[source]#
go = None[source]#
num_parameters[source]#
sig_digits = 4[source]#