# Dice Roll P-value without normal approximation

I am testing a sample where $$H_0: p_0 =1/6$$ against $$H_a: p_0 \ne 1/6.$$ The problem asked is to Calculate the p-value given that a normal distribution isn't met. Given that the large counts and 10 percent condition aren't met how do you calculate the p-value of a hypothesis without using a normal approximation? Are there other distributions I can use or... is there a specific method or formula?

• From the title, it seems dice are rolled. What is p0? Is it the probability of a particular face of the die, say 1. Or is this shorthand for asking if the die is fair so that all faces have probability $1/6.?$ How many times do would you roll the die to get data to test $H_0$ against $H_a?$ // I have written an answer to provide some structure for your question. Hope it is useful. Mar 6 at 7:46

If you roll a die, in order to test whether all six faces are equally likely, then the number of rolls $$n$$ required for a useful test depends on the amount of unfairness we want to be reasonably sure to detect.

A chi-squared test of goodness-of-fit is often used to test whether a die is fair. Suppose a die is biased in favor of 1's and against 6's so that the vector of its six true probabilities is $$(4/18, 3/18, 3/18, 3/18, 3/18, 2/18).$$ is $$n = 600$$ rolls of this die sufficient to detect particular bias.

In order to see how the test of the null hypothesis that the die is fair against the alternative that it is not, we use R to sample 600 rolls of the die, and then run the chi-squared test:

The sample function in R can simulate 600 rolls of the die as follows:

set.seed(305)
pr = c(4,3,3, 3,3,2)/18
x = sample(1:6, 600, rep=T, p=pr)
t = tabulate(x); t
 139 104 107  90  89  71


If the die were fair, we would expect each face to appear on average 100 times. These are the expected counts $$E_i.$$ The observed counts for our particular 600 rolls were $$T = (139, 104, \dots, 71)$$ as shown in the R output above. The chi-squared statistic is $$Q = \sum_{i=1}^6 \frac{(T_i = E_i)^2}{E_i} = 26.48.$$

T = c(139, 104, 107,  90,  89,  71)
E = rep(100, 6)
Q = sum((T-E)^2/E);  Q
 26.48


If the die were fair the approximate (null) distribution of the test statistic would be $Q \sim \mathsf{Chisq}(\nu=6-1=5), the chi-squared distribution with five degrees of freedom (one less than the number of faces). For a test at the 5% level, we would reject $$H_0$$ if $$Q$$ is above the 95th percentile of $$\mathsf{Chisq}(5),$$ called the critical value $$c=11.07$$ of this test. c = qchisq(.95, 5); c  11.0705  Because our observed value $$Q = 26.48 > c = 11.07,$$ we reject. The P-value of the test is the probability under the null distribution of observing a value larger than $$Q = 26.48.$$ Here the P-value is very nearly $$0.$$ We would reject at the 5% level for any P-value smaller than $$0.05=5\%.$$ pv = 1 - pchisq(26.48, 5); pv  7.20038e-05  In R, the procedure chisq.test does the test and gives its P-value. chisq.test(t) Chi-squared test for given probabilities data: t X-squared = 26.48, df = 5, p-value = 7.2e-05  [Unless the contrary is stated, chisq.test assumes the 'given probabilities' are all equal.] In this particular example, 600 rolls of the die were enough to allow us to reject $$H_0,$$ thus detecting that our die is unfair. In a simulation of 100,000 such chi-squared tests, the null hypothesis was rejected over 97% of the time, so 600 rolls give power about 97% against the alternative that ones have probability $$4/18$$ ans sixes have probability $$2/18.$$ set.seed(2021) pr = c(4,3,3, 3,3,2)/18 pv = replicate(10^5, chisq.test( tabulate(sample(1:6, 600, rep=T, p=pr)) )$p.val)
mean(pv <= .05)
 0.97428


However, in the same situation, but with evidence from only 120 rolls of such a biased die, we have power only about 32%. So, 600 is enough and 120 is not enough reliably to detect this bias.

set.seed(1234)
pr = c(4,3,3, 3,3,2)/18
pv = replicate(10^5, chisq.test(
tabulate(sample(1:6, 120, rep=T, p=pr)) )\$p.val)
mean(pv <= .05)
 0.31935


Note: If interested in more detail, you may want look at this Q&A, has additional comments on computing the power of a chi-squared goodness-of-fit test, including the use of the non-central chi-squared distribution.