Project 45: Chi Square GOF
Intro Problem: A school administrator believes that the distribution of student grade levels are as follows:
9th Grade: 35%
10th Grade: 30%
11th Grade: 20%
12th Grade: 15%
To test the claim at the .05 level, she randomly samples a group of students from the school and obtains the following:
9th graders: 60
10th graders: 50
11th graders: 40
12th graders: 30
Explanation:
Ho: p9 = .35, p10 = .3, p11 = .2, p12 = .15 (model)
Ha: the model posed is not a good fit
n = 60 + 50 + 40 + 30 = 180
Expected Counts: 180(.35) = 63, 180(.3) = 54, 180(.2) = 36, 180(.15) = 27
Chi Square Test Statistic: (60-63)^2/63 + (50-54)^2/54 + (40-36)^2/36 + (30-27)^2/27 = 1.22
Degrees of Freedom = number of categories - 1 = 4 - 1 = 3
pValue = .75 (which is the probability that a chi square value is greater than 1.22 with 3 degrees of freedom)
Since .75 > .05 we would fail to reject Ho and not get evidence that the administrator's claim is incorrect.
Project 45: The variables 'model' and 'counts' have been initialized. There is also a working method called chicdf.
model represents the distribution of expected proportions ([.35, .3, .2, .15] in the example above)
counts represents the actual counts observed ([60, 50, 40, 30] in the example above)
chicdf(low, high, df) returns the probability that a chi square value is between low and high (with 'df' degrees of freedom)
Task: Appropriately initialize the values of 'chi' and 'pValue' that represents the chi square test statistic and the p-value for the goodness of fit test.
**If your code works for 5 test cases, you can enter your e-mail address
Universal Computational Math Methods:
pow(5,2) returns 25.0
abs(-3.0) returns 3
sqrt(49.0) returns 7.0