The Statistics package provides two methods of testing goodnessoffit. The ChiSquareGoodnessOfFitTest function should be used to determine if an observed or empirical data set fits expected values for that data set. Similarly, the ChiSquareSuitableModelTest is available for testing how well a given probability distribution approximates a data sample.
>

$\mathrm{restart}\:\phantom{\rule[0.0ex]{0.0em}{0.0ex}}\phantom{\rule[0.0ex]{0.0em}{0.0ex}}$$\mathrm{with}\left(\mathrm{Statistics}\right)\:\phantom{\rule[0.0ex]{0.0em}{0.0ex}}\phantom{\rule[0.0ex]{0.0em}{0.0ex}}$$\mathrm{infolevel}\left[\mathrm{Statistics}\right]\u22541\:$

Consider the following number of sales made on each day of the week at a jewelry store, tallied over one sales week (Monday to Saturday).
>

$\mathrm{Ob}:=\mathrm{Array}\left(\left[25\,17\,15\,23\,24\,16\right]\right)$

${\mathrm{Ob}}{:=}\left[\begin{array}{cccccc}{25}& {17}& {15}& {23}& {24}& {16}\end{array}\right]$
 (5.1) 
We wish to test the hypothesis that sales are uniformly distributed throughout the week. The expected number of sales per day is then given by the number of sales averaged over the week.
>

$\mathrm{SalesPerDay}:=\frac{\sum _{i\=1}^{6}\phantom{\rule[0.0ex]{5.0px}{0.0ex}}{\'\mathrm{Ob}\'}_{i}}{6}$

${\mathrm{SalesPerDay}}{:=}{20}$
 (5.2) 
>

$\mathrm{Ex}:=\mathrm{Array}\left(\left[\mathrm{SalesPerDay}\$6\right]\right)$

${\mathrm{Ex}}{:=}\left[\begin{array}{cccccc}{20}& {20}& {20}& {20}& {20}& {20}\end{array}\right]$
 (5.3) 
We now test the hypothesis (using ChiSquareGoodnessOfFitTest) that the observed number of sales per day is consistent with a uniformly distributed number of sales each day.
>

$\mathrm{ChiSquareGoodnessOfFitTest}\left(\mathrm{Ob}\,\mathrm{Ex}\,\mathrm{level}\=0.05\right)\:$

ChiSquare Test for GoodnessofFit

Null Hypothesis:
Observed sample does not differ from expected sample
Alt. Hypothesis:
Observed sample differs from expected sample
Categories: 6
Distribution: ChiSquare(5)
Computed statistic: 5
Computed pvalue: 0.41588
Critical value: 11.07049741
Result: [Accepted]
There is no statistical evidence against the null hypothesis
 
Hence we conclude that a uniformly distributed number of sales is a reasonable claim.
Consider a dataset of times during a day when sales are made. Determine if sales are uniformly distributed during the day (consider an 8 hour working day where sales are measured between 0.0 and 8.0, the number of hours into the day). The data in this case is continuous and we are testing against a uniform probability distribution.
>

$\mathrm{SaleTimes}:=\left[1.4\,1.8\,2.2\,2.9\,3.0\,3.4\,3.4\,3.5\,3.6\,3.7\,3.8\,4.0\,4.4\,4.6\,5.3\,7.5\right]\:$

Apply the chi square suitable model test to determine if a uniform distribution closely matches the provided data.
>

$\mathrm{ChiSquareSuitableModelTest}\left(\mathrm{SaleTimes}\,\mathrm{Uniform}\left(0\,8\right)\right)\:$

ChiSquare Test for Suitable Probability Model

Null Hypothesis:
Sample was drawn from specified probability distribution
Alt. Hypothesis:
Sample was not drawn from specified probability distribution
Bins: 4
Distribution: ChiSquare(3)
Computed statistic: 9.5191
Computed pvalue: 0.023129
Critical value: 7.814728288
Result: [Rejected]
There exists statistical evidence against the null hypothesis
 
Hence we conclude that the sale times are not uniformly distributed throughout the day. Closer examination of the data reveals that most of the sales were made roughly half way through the day.