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

Calculate estimate of the effective sample size.

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

ess : xarray.Dataset

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


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 Section 15.4.2

Gelman et al. BDA (2014) Formula 11.8