GUIBRUSHR.Retrieval.ExofastMCMC.exofast_gelmanrubin module¶
Gelman-Rubin convergence diagnostic implementation.
This module implements the Gelman-Rubin convergence diagnostic for MCMC chains as described in Ford 2006. The diagnostic is used to assess whether multiple MCMC chains have converged to the same distribution.
References
Ford, E. B. (2006). Improving the efficiency of Markov chain Monte Carlo for analyzing the orbits of extrasolar planets. The Astrophysical Journal, 642(1), 505.
- GUIBRUSHR.Retrieval.ExofastMCMC.exofast_gelmanrubin.exofast_gelmanrubin(pars0)[source]¶
Calculate the Gelman-Rubin convergence diagnostic for MCMC chains.
This function implements the Gelman-Rubin diagnostic (R-hat) to assess convergence of multiple MCMC chains. The diagnostic compares within-chain and between-chain variances to determine if chains have converged.
The function follows the equations from Ford 2006: - Equation 21: W(z) - within-chain variance - Equation 23: B(z) - between-chain variance - Equation 24: varhat+(z) - pooled variance estimate - Equation 25: Rhat(z) - Gelman-Rubin statistic - Equation 26: T(z) - effective sample size factor
- Parameters:
pars0 – 3D numpy array with shape (npars, nsteps, nchains) where npars is the number of parameters, nsteps is the number of MCMC steps, nchains is the number of independent chains
- Returns:
- (converged, gelmanrubin, tz) where:
converged: int, 1 if converged, 0 if not converged
gelmanrubin: numpy array of R-hat values for each parameter
tz: numpy array of effective sample size factors
- Return type:
tuple
Notes
Convergence is determined when: - All R-hat values < 1.01 - All effective sample sizes > 1000