Autocorrelation

autocorrelation(x, axis=0)[source]

Computes the autocorrelation of samples at dimension axis.

Parameters:
  • x (numpy.ndarray) – the input array.
  • axis (int) – the dimension to calculate autocorrelation.
Returns:

autocorrelation of x.

Return type:

numpy.ndarray

Autocovariance

autocovariance(x, axis=0)[source]

Computes the autocovariance of samples at dimension axis.

Parameters:
  • x (numpy.ndarray) – the input array.
  • axis (int) – the dimension to calculate autocovariance.
Returns:

autocovariance of x.

Return type:

numpy.ndarray

Effective Sample Size

effective_sample_size(x)[source]

Computes effective sample size of input x, where the first dimension of x is chain dimension and the second dimension of x is draw dimension.

References:

  1. Introduction to Markov Chain Monte Carlo, Charles J. Geyer
  2. Stan Reference Manual version 2.18, Stan Development Team
Parameters:x (numpy.ndarray) – the input array.
Returns:effective sample size of x.
Return type:numpy.ndarray

Gelman Rubin

gelman_rubin(x)[source]

Computes R-hat over chains of samples x, where the first dimension of x is chain dimension and the second dimension of x is draw dimension. It is required that input.shape[0] >= 2 and input.shape[1] >= 2.

Parameters:x (numpy.ndarray) – the input array.
Returns:R-hat of x.
Return type:numpy.ndarray

Split Gelman Rubin

split_gelman_rubin(x)[source]

Computes split R-hat over chains of samples x, where the first dimension of x is chain dimension and the second dimension of x is draw dimension. It is required that input.shape[1] >= 4.

Parameters:x (numpy.ndarray) – the input array.
Returns:split R-hat of x.
Return type:numpy.ndarray

HPDI

hpdi(x, prob=0.89, axis=0)[source]

Computes “highest posterior density interval” (HPDI) which is the narrowest interval with probability mass prob.

Parameters:
  • x (numpy.ndarray) – the input array.
  • prob (float) – the probability mass of samples within the interval.
  • axis (int) – the dimension to calculate hpdi.
Returns:

quantiles of input at (1 - probs) / 2 and (1 + probs) / 2.

Return type:

numpy.ndarray

Summary

summary(samples, prob=0.89)[source]

Prints a summary table displaying diagnostics of samples from the posterior. The diagnostics displayed are mean, standard deviation, the 89% Credibility Interval, effective_sample_size() split_gelman_rubin().

Parameters:
  • samples – a collection of input samples.
  • prob (float) – the probability mass of samples within the HPDI interval.