statsmodels.stats.gof.gof_chisquare_discrete#

statsmodels.stats.gof.gof_chisquare_discrete(distfn, arg, rvs, alpha, msg)[source]#

Perform chisquare test for random sample of a discrete distribution

Parameters:
distfndistribution instance

Discrete distribution function to be tested; needs support, ppf and cdf methods.

argsequence

parameters of distribution

rvsarray_like

random sample from the distribution to be tested

alphafloat

significance level, threshold for p-value

msgstr

identifying message that is included in the returned result string

Returns:
chisfloat

chisquare statistic of the test

pvalfloat

p-value of the test based on the chisquare distribution

truefalsebool

True if the test passes (pval > alpha), False if it fails

outstrstr

summary string describing the test and its result

Notes

originally written for scipy.stats test suite, still needs to be checked for standalone usage, insufficient input checking may not run yet (after copy/paste)

The bins are computed by gof_binning_discrete with its default number of bins. Observations outside the support of the distribution are dropped. The last bin can have a very small expected count, which makes the chisquare approximation of the p-value unreliable.

Changed in version 0.15.1: The support of the distribution is taken from distfn.support(*arg) instead of a fixed window of integers from -1000 to 1000. The bins now follow loc shifts and large means.

refactor: maybe a class, check returns, or separate binning from

test results