effective_sample_size

effective_sample_size(posteriors: dict[str, ndarray], print_summary: bool = True) DataFrame

It computes and prints the effective number of sample for each posterior.

Parameters

posteriorsdict

Posterior samples. Posteriors and relative samples are key-value pairs. Each sample is a numpy.ndarray with a number of rows equals to the number of iterations and a number of columns equal to the number of Markov chains.

print_summarybool, optional

If True prints the effective sample size summary report. Default is True.

Returns

pandas.DataFrame

The dataframe with a single row and a number of columns equal to the number of model variables. The unique index of the dataframe is 'Effective Sample Size'.

Raises

TypeError
  • If posteriors is not a dict,

  • if a posterior sample is not a numpy.ndarray,

  • if print_summary is not a bool.

KeyError

If posteriors does not contain 'intercept' key.

ValueError

If a posterior sample is an empty numpy.ndarray.

Notes

The effective number of sample could be theoretically equal to the number of iterations in case of no auto-correlation of the Markov chain. The greater the auto-correlation of the Markov chain, the smaller the effective sample size of the posterior.

See Also

autocorrelation_plot

autocorrelation_summary