arviz.effective_sample_size

arviz.effective_sample_size(data, *, var_names=None)[source]

Calculate estimate of the effective sample size.

Parameters:
data : obj

Any object that can be converted to an az.InferenceData object Refer to documentation of az.convert_to_dataset for details At least 2 posterior chains are needed to compute this diagnostic of one or more stochastic parameters.

var_names : list

Names of variables to include in the effective_sample_size report

Returns:
ess : xarray.Dataset

Return the effective sample size, \(\hat{N}_{eff}\)

Notes

The diagnostic is computed by:

\[\hat{N}_{eff} = \frac{MN}{\hat{\tau}}\]
\[\hat{\tau} = -1 + 2 \sum_{t'=0}^K \hat{P}_t'\]

where \(\hat{\rho}_t\) is the estimated _autocorrelation at lag t, and T is the first odd positive integer for which the sum \(\hat{\rho}_{T+1} + \hat{\rho}_{T+1}\) is negative.

The current implementation is similar to Stan, which uses Geyer’s initial monotone sequence criterion (Geyer, 1992; Geyer, 2011).

References

https://mc-stan.org/docs/2_18/reference-manual/effective-sample-size-section.html Section 15.4.2

Gelman et al. BDA (2014) Formula 11.8