gwin.gelman_rubin module¶
This modules provides functions for evaluating the Gelman-Rubin convergence diagnostic statistic.
-
gwin.gelman_rubin.
gelman_rubin
(chains, auto_burn_in=True)[source]¶ Calculates the univariate Gelman-Rubin convergence statistic which compares the evolution of multiple chains in a Markov-Chain Monte Carlo process and computes their difference to determine their convergence. The between-chain and within-chain variances are computed for each sampling parameter, and a weighted combination of the two is used to determine the convergence. As the chains converge, the point scale reduction factor should go to 1.
Parameters: - chains (iterable) – An iterable of numpy.array instances that contain the samples for each chain. Each chain has shape (nparameters, niterations).
- auto_burn_in (bool) – If True, then only use later half of samples provided.
Returns: psrf – A numpy.array of shape (nparameters) that has the point estimates of the potential scale reduction factor.
Return type: numpy.array
-
gwin.gelman_rubin.
walk
(chains, start, end, step)[source]¶ Calculates Gelman-Rubin conervergence statistic along chains of data. This function will advance along the chains and calculate the statistic for each step.
Parameters: - chains (iterable) – An iterable of numpy.array instances that contain the samples for each chain. Each chain has shape (nparameters, niterations).
- start (float) – Start index of blocks to calculate all statistics.
- end (float) – Last index of blocks to calculate statistics.
- step (float) – Step size to take for next block.
Returns: - starts (numpy.array) – 1-D array of start indexes of calculations.
- ends (numpy.array) – 1-D array of end indexes of caluclations.
- stats (numpy.array) – Array with convergence statistic. It has shape (nparameters, ncalculations).