Effective sample size (Python)

Effective sample size (Python)

Basic explanation of the effective sample size goes here. i.e. we recommend having 100 ess (bulk and tail) per chain and a minimum of 4 chains. However, you should check with helper_function_x that you have already achieved the desired precision in case you need some more samples.

import arviz as az
idata = az.load_arviz_data("non_centered_eight")
az.ess(idata)
<xarray.Dataset>
Dimensions:  (school: 8)
Coordinates:
  * school   (school) object 'Choate' 'Deerfield' ... "St. Paul's" 'Mt. Hermon'
Data variables:
    mu       float64 2.354e+03
    theta_t  (school) float64 2.215e+03 3.159e+03 ... 2.678e+03 2.522e+03
    tau      float64 1.268e+03
    theta    (school) float64 2.298e+03 2.434e+03 ... 2.174e+03 2.278e+03

Here there is a note about how bulk and tail ess differ

az.ess(idata, method="tail")
<xarray.Dataset>
Dimensions:  (school: 8)
Coordinates:
  * school   (school) object 'Choate' 'Deerfield' ... "St. Paul's" 'Mt. Hermon'
Data variables:
    mu       float64 1.401e+03
    theta_t  (school) float64 1.45e+03 1.514e+03 ... 1.207e+03 1.589e+03
    tau      float64 900.0
    theta    (school) float64 1.445e+03 1.506e+03 ... 1.433e+03 1.418e+03

ess is a very important diagnostic, you should always use it on your posterior samples before doing any analysis with them