A die is thrown $150$ times with the following results, No of tossed up - 1 2 3 4 5 6 and the frequency will be $19,23,28,17,32,31$.

I got the value for $(O-E)^2$ as $198..$ E is $25$.

I got the $X_2$ value as $7.92$ but in my text book it shows as $7.32$

Not sure where did I go wrong.Can someone help me with the right answer ?

  • 1
    $\begingroup$ $7.92= (36+4+9+64+49+36)/25$ looks reasonable $\endgroup$
    – Henry
    Jun 14, 2019 at 13:08

1 Answer 1


I assume you are testing the null hypothesis that the die is fair.

Chi-squared statistic. As as stated in @Henry's Comment, the chi-squared statistic for your data computes to $$Q = \sum_{i=1}^6 \frac {(X_i - E_i)^2}{E_i} = 7.92.$$

Using R as a calculator:

X = c(19, 23, 28, 17, 32, 31);  X
[1] 19 23 28 17 32 31
E = mean(X);  E
[1] 25
X - E
[1] -6 -2  3 -8  7  6
[1] 36  4  9 64 49 36
[1] 1.44 0.16 0.36 2.56 1.96 1.44
[1] 7.92

If the die is fair, then $Q \stackrel{aprx}{\sim} \mathsf{Chisq}(\nu = 6-1 = 5).$

Critical value for test at 5% level. The critical value for a test at the 5% level is $c = 11.0705.$ Because $Q < c$ you cannot reject the null hypothesis, so you conclude that your 150 observed rolls of the die are consistent with a fair die.

qchisq(.95, 5)
[1] 11.0705

P-value of the test. The P-value is the probability in the right-hand tail of $\mathsf{Chisq}(5)$ beyond the observed value $Q = 7.92.$ That is, $0.1607 > 0.05,$ so you cannot reject the null hypothesis.

1 - pchisq(7.92, 5)
[1] 0.1607

In the figure below the density function of $\mathsf{Chisq}(5)$ is shown along with the observed value $Q = 7.92$ (solid vertical line) and the critical value $c = 11.0705$ (dotted vertical line). The P-value is represented by the area to the right of the solid vertical line.

Plot of density

Chi-squared goodness-of-fit test in R. In R statistical software, this test is performed as shown below. (The default null hypothesis is that categories are equally likely.)


        Chi-squared test for given probabilities

data:  X
X-squared = 7.92, df = 5, p-value = 0.1607

Does $Q$ really have a chi-squared distribution? The test statistic has nearly a chi-squared distribution. As the sample size become infinite, the approximate becomes better. Simulation studies have shown that the fit is quite good provided that the expected count for each category (face of the die) is 5 or greater; here we have $E = 25.$

The simulation below shows that the true significance level using critical value $c = 11.0705.$ is very nearly 5%. The simulation is based on finding the value $Q$ for a million 150-roll experiments with a fair die.

q = replicate(10^6, 
chisq.test(tabulate(sample(1:6, 150, rep=T)))$stat)
c = qchisq(.95, 5);  mean(q >= c)
[1] 0.049564

The histogram of the one million simulated values of $Q$ is shown below along with the density curve of $\mathsf{Chisq}(5).$ The proportion of the simulated $Q$'s to the right of the critical value $c$ is very nearly 5%.

enter image description here

Power of the goodness-of-fit test. If your die is biased, then it is reasonable to ask how likely the test is to reject the null hypothesis. That probability is called the 'power' of the test.

Suppose we roll a 'loaded' die (perhaps with a lead weight embedded under face 1), for which the probability of getting 1 is $1/18,$ the probability of getting 6 is $5/18,$ and all other faces have probability $1/6.$

Thus the probability vector is not $p_0 = (1/6, 1/6, \dots, 1/6),$ as specified by the null hypothesis, but is has the alternative values $p_a = (1/18, 1/6, 1/6, 1/6, 1/6, 5/18).$

A simulation with such a biased die is shown below. We see that the power of the test against this alternative distribution is about 98.5%. So we the test is almost sure to reject the null hypothesis that such a die is fair.

set.seed(2019) ; p.a=c(1,3,3,3,3,5)/18
q = replicate(10^6, 
chisq.test(tabulate(sample(1:6, 150, rep=T, prob=p.a)))$stat)
c = qchisq(.95, 5)
mean(q >= c)
[1] 0.984847

enter image description here

Theoretically, for large sample sizes, the distribution of the test statistic $Q$ is now a noncentral chi-squared distribution. The noncentrality parameter is

$$\lambda = n\sum_{i=1}^6 \frac{(p_{ai}-p_{0i})^2}{p_{01}}.$$

Using the noncentrality parameter, we can get the approximate power of the goodness-of-fit test against this specified alternative as 97.1%, which is not far from what we got from the simulation.

p.a = c(1,3,3,3,3,5)/18
lam = 150*sum((p.a-1/6)^2/(1/6)); lam
[1] 22.22222
1 - pchisq(c, 5, lam)
[1] 0.9709793

If the die were less heavily biased so that the respective values of faces 1 trough 6 are $p_a = c(2/18, 1/6, 1/6, 1/6, 1/6, 4/18),$ then the power of the test would be only about 40%.

p.a = c(2,3,3,3,3,4)/18
lam = 150*sum((p.a-1/6)^2/(1/6)); lam
[1] 5.555556
1 - pchisq(c, 5, lam)
[1] 0.4018898

References; See Wikipedia for a basic explanation of the noncentral chi-squared distribution. This paper by W. Guenther in The American Statistician (1988) shows the use of the noncentral distribution in power computations for goodness-of-fit tests.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .