# Checking if a coin is fair: z-test or t-test

I have seen many questions on this topic, but none of them could answer my question. Suppose I flip a coin 1,000 times and got 490 heads. I want to test if the coin is fair. I don't want to use the binomial distribution but instead I'd like to use the normal approximation. I want to test $$H_0: p = 0.5$$ vs $$H_1 : p \neq 0.5$$.

If I use the t-test, I would have to estimate the sample variance, and the reason for using a t-test would be that I don't know the population variance.

However, is it actually true that I don't know the population variance? I'm supposed to compute a test statistic, assuming that null is true. If I assume the null is true, I do know the population variance, because I know $$p$$ (because I assume $$p = 0.5$$). I should then use the z test.

Which test should I use, and why?

Use the z test.

In the case where you assume the binomial parameter is $$p=p_0$$, then the variance would be determined since it is a function of the binomial parameter. If I recall correctly, the resulting test statistic would be a score statistic.

In the case where you use the estimated binomial parameter in the variance (resulting in a Wald statistic if I remember correctly, though I might have permuted those) you would still use a z test because the variance is determined by the estimate of the binomial parameter.

• I think you got them reversed. The default in R for logistic regression is to use a z-test on the coefficients, and I’m pretty sure that’s a Wald test (though I am open to being wrong about this).
– Dave
Jun 30, 2021 at 3:49
• @Dave Nope, just checked. A Wald test statistic uses the estimated sample mean in the variance computation. A score statistic uses the variance under the null. I would derive these in my answer but its quite late here. Jun 30, 2021 at 3:53
• I’ll have to check out if the R default is Wald. I always thought it was, but now I wonder if it is a score test.
– Dave
Jun 30, 2021 at 3:57
• If I were to use the sample variance instead of the population variance, wouldn't I end up with a t statistic? Jun 30, 2021 at 14:19
• @user1691278 no, because the sample variance is a function of the sample mean. You don't have to estimate it independently and hence no additional error is introduced. Jun 30, 2021 at 14:24

In R, an exact binomial test binom.test of $$H_0: p= 1/2$$ vs. $$H_a: p\ne 1/2$$ fails to reject $$H_0$$ with P-value $$0.5479727.$$ The second R statement below shows how the P-value is computed using binomial CDFs pbinom.

binom.test(490,1000, 1/2)$p.val  0.5479727 pbinom(490, 1000, .5) + 1 - pbinom(509, 1000, .5)  0.5479727  Also, prop.test, which uses a normal approximation gives P-value $$0.5479514.$$ The second R statement shows how the approximate P-value can be computed using normal CDFs pnorm, with continuity correction. prop.test(490,1000, 1/2)$p.val
 0.5479514
2*pnorm(490.5, 500, sqrt(250))
 0.5479514


I don't understand your aversion to exact binomial tests, but for $$n$$ in the hundreds or thousands, there will be very little difference using normal approximations--especially when hypothetical $$p \approx 1/2.$$ 