def multivariate_ess_precision(nmr_params, multi_variate_ess, alpha=0.05):
    r"""Calculate the precision given your multivariate Effective Sample Size.

    Given that you obtained :math:`ESS` multivariate effective samples in your estimate you can calculate the
    precision with which you approximated your desired confidence region.

    This implements the inequality from Vats et al. (2016), slightly restructured to give :math:`\epsilon` back instead
    of the minimum ESS.

    .. math::

         \epsilon = \sqrt{\frac{2^{2/p}\pi}{(p\Gamma(p/2))^{2/p}} \frac{\chi^{2}_{1-\alpha,p}}{\widehat{ESS}}}

    Where :math:`p` is the number of free parameters and ESS is the multivariate ESS from your samples.

    Args:
        nmr_params (int): the number of free parameters in the model
        multi_variate_ess (int): the number of iid samples you obtained in your sample results.
        alpha (float): the level of confidence of the confidence region. For example, an alpha of 0.05 means
            that we want to be in a 95% confidence region.

    Returns:
        float: the minimum multivariate Effective Sample Size that one should aim for in MCMC sample to
            obtain the desired confidence region with the desired precision.

    References:
        Vats D, Flegal J, Jones G (2016). Multivariate Output Analysis for Markov Chain Monte Carlo.
        arXiv:1512.07713v2 [math.ST]
    """
    tmp = 2.0 / nmr_params
    log_min_ess = tmp * np.log(2) + np.log(np.pi) - tmp * (np.log(nmr_params) + gammaln(nmr_params / 2)) \
                  + np.log(chi2.ppf(1 - alpha, nmr_params)) - np.log(multi_variate_ess)
    return np.sqrt(np.exp(log_min_ess))
r"""Calculate the precision given your multivariate Effective Sample Size.

    Given that you obtained :math:`ESS` multivariate effective samples in your estimate you can calculate the
    precision with which you approximated your desired confidence region.

    This implements the inequality from Vats et al. (2016), slightly restructured to give :math:`\epsilon` back instead
    of the minimum ESS.

    .. math::

         \epsilon = \sqrt{\frac{2^{2/p}\pi}{(p\Gamma(p/2))^{2/p}} \frac{\chi^{2}_{1-\alpha,p}}{\widehat{ESS}}}

    Where :math:`p` is the number of free parameters and ESS is the multivariate ESS from your samples.

    Args:
        nmr_params (int): the number of free parameters in the model
        multi_variate_ess (int): the number of iid samples you obtained in your sample results.
        alpha (float): the level of confidence of the confidence region. For example, an alpha of 0.05 means
            that we want to be in a 95% confidence region.

    Returns:
        float: the minimum multivariate Effective Sample Size that one should aim for in MCMC sample to
            obtain the desired confidence region with the desired precision.

    References:
        Vats D, Flegal J, Jones G (2016). Multivariate Output Analysis for Markov Chain Monte Carlo.
        arXiv:1512.07713v2 [math.ST]