> "Here is a program that will help you to do a chi-squared test. Hit return in order to load it.":

with(plots):

with(plottools):

ChiTest:=proc(E,F)
local r,s,i,m;
m:=nops(E)-1;
r:=0;
for i from 1 to nops(E)
do
r:=r+((E[i]-F[i])^2)/E[i];
od;
s:=evalf(100*(1-stats[statevalf,cdf,chisquare[nops(E)-1]](r)));
lprint("The chi-squred value is",evalf(r),"where there are",
nops(E),"classes, and a probabilty of about ",
s,"percent that the null hypothesis is true and we see such chi squared value.");
if
s > 5
then
lprint("In particular this test is not significant and we should not reject the null hypothesis based on it");
fi;

if
1<s and s<= 5
then
lprint("In particular this test is significant and we may reject the null hypothesis based on it");
fi;
if
s<=1 then
lprint("In particular this test is highly significant and we may reject the null hypothesis based on it");
fi;

A1:=plot(stats[statevalf,pdf,chisquare[m]](x),x=0..r+5):

A2:=pointplot({[r,stats[statevalf,pdf,chisquare[m]](r)]},color=blue,symbol=diamond,thickness=2):

display(A1,A2);


end:

Warning, `A1` is implicitly declared local to procedure `ChiTest`

Warning, `A2` is implicitly declared local to procedure `ChiTest`

> "To use this program simply change the first list to your list of expected numbers, and the second to your list of observed numbers, then hit return.":

ChiTest([(1/4)*100,(1/4)*100,(1/4)*100,(1/4)*100 ],[22,20,28,30]);

"The chi-squred value is", 2.720000000, "where there are", 4, "classes, and a probabilty of about ", 43.68391968, "percent that the null hypothesis is true and we see such chi squared value."

"In particular this test is not significant and we should not reject the null hypothesis based on it"

[Maple Plot]

>