Args:
        mcmc (MCMCResults): Pre-sliced MCMC samples to compute diagnostics for.

def gelman_rubin(mcmc):
    """
    Args:
        mcmc (MCMCResults): Pre-sliced MCMC samples to compute diagnostics for.
    """

    if mcmc.n_chains < 2:
        raise ValueError(
            'Gelman-Rubin diagnostic requires multiple chains '
            'of the same length.')

    # get Vhat and within-chain variance
    Vhat, W = _vhat_w(mcmc)

    # compute and return Gelman-Rubin statistic
    Rhat = np.sqrt(Vhat / W)
    return pd.DataFrame({'gelman_rubin': Rhat}, index=mcmc.levels)