# chi2test¶

class reliability.Reliability_testing.chi2test(distribution, data, significance=0.05, bins=None, print_results=True, show_plot=True)

Performs the Chi-squared test for goodness of fit to determine whether we can accept or reject the hypothesis that the data is from the specified distribution at the specified level of significance. This method is not a means of comparing distributions (which can be done with AICc, BIC, and AD), but instead allows us to accept or reject a hypothesis that data come from a distribution. Note that the result is sensitive to the bins. For this reason, it is recommended to leave bins as the default value.

Inputs: distribution - a distribution object created using the reliability.Distributions module data - an array or list of data that are hypothesised to come from the distribution significance - This is the complement of confidence. 0.05 significance is the same as 95% confidence. Must be between 0 and 0.5. Default is 0.05. bins - an array or list of the bin edges from which to group the data OR a string for the bin edge method from numpy. String options are auto, fd, doane, scott, stone, rice, sturges, or sqrt. For more information see the numpy documentation on numpy.histogram_bin_edges. Default is auto. print_results - if True the results will be printed. Default is True show_plot - if True a plot of the distribution and histogram will be shown. Default is True.

Outputs: chisquared_statistic - the chi-squared statistic chisquared_critical_value - the chi-squared critical value hypothesis - ‘ACCEPT’ or ‘REJECT’. If chisquared_statistic < chisquared_critical_value then we can accept the hypothesis that the data is from the specified distribution bin_edges - the bin edges used. If bins is a list or array then bin_edges = bins. If bins is a string then you can find the bin_edges that were calculated using this output.