# Test to determine whether coin is fair or not

A coin is tossed 10 times. How can we determine whether it is fair or not?

My approach:
This seems to be like a Binomial experiment. I know that for a fair coin, the fraction of heads should be 0.5.

• Null Hypothesis: fraction of Head is 0.5
• Alternative Hypothesis: fraction of Head is not 0.5

But how do you calculate any statistic ?

The mean, I guess, is $$n \times p$$. The std. dev. is $$\sqrt{(np(1-p))}$$.

If some knows the answer please tell me. Also please let me know if my approach is right or wrong.

• Commented Jun 11, 2021 at 18:43
• The null hypothesis is formulated in terms of the unknown parameter, not the data. In this case the unknown parameter is p. Commented Jun 11, 2021 at 19:02
• You have the correct null and alternative hypotheses. Also a hint of a start towards doing an approximate normal version of this binomial test. Commented Jun 11, 2021 at 22:19
• @BruceET, can we use normal approximation here ? Just asking because I read somewhere that if sample size is less than 30 then use T-test instead of Z-test. Also here tossing a coin 10 times and counting heads is the event does that mean sample size is 1 ? Commented Jun 14, 2021 at 5:27

Ten tosses of a coin. Test $$H_0: p = 1/2$$ against $$H_0: p \ne 1/2.$$ Comment at the start: there is not a lot of information in only ten tosses of a coin, so in order to reject $$H_0$$ we will have to observe very few heads (0 or 1) or very many (9 or 10).

Normal approximation: Under $$H_0,$$ Number $$X$$ of heads see in $$n = 10$$ independent tosses has $$X \sim\mathsf{Binom}(n=10,p=1/2,$$ which has $$\mu = E(X) = np = 5,$$ and $$\sigma = \sqrt{np(1-p)} = \sqrt{2.5} = 1.581139.$$ Then $$Z = \frac{X=\mu}{\sigma} \stackrel{aprx}{\sim} \mathsf{Norm}(0,1).$$ So we reject $$H_0$$ at about the 5% level by rejecting for $$|Z| \ge 1.96.$$

Example: Suppose you observe $$x = 3$$ heads in $$n = 10$$ tosses. then $$|Z|=|\frac{3-5}{1.5811}| = |-1.265| < 1.96,$$ so you do not have sufficient evidence to reject $$H_0$$ at the 5% level of significance.

Exact binomial test. This two-sided test rejects $$H_0$$ when $$X$$ is sufficiently far from the expected value $$\mu=5$$ under $$H_0.$$ For observed value $$x,$$ the P-value is $$P(X \le x)+P(X \ge n-x).$$

Example: Same as above: $$x = 3.$$ We seek $$P(X \le 3) + P(X \ge 7) = 0.3438 > 0.05 = 5\%,$$ so we do not reject $$H_0$$ at the 5% level of significance.

sum(dbinom(c(0:3, 7:10), 10, .5))
[1] 0.34375


This exact binomial test is implemented in R as 'binom.test', which gives the same P-value $$0.3438$$ that we obtained from the binomial distribution above.

binom.test(x=3, n=10, p=.5)

Exact binomial test

data:  3 and 10
number of successes = 3, number of trials = 10, p-value = 0.3438
alternative hypothesis:
true probability of success is not equal to 0.5
95 percent confidence interval:
0.06673951 0.65245285
sample estimates:
probability of success
0.3


Notes: (a) Back to the comment at the beginning. For the exact binomial test the rejection region for $$H_0: p=.5$$ against $$H_a: p \ne .5$$ is to observe $$0,1,9,$$ or $$10$$ Heads, so this is really a test at about the 2% level. (Including $$2$$ and $$8$$ in the rejection region would make it a test at about the 11% level. Because of the discreteness of binomial distributions a straightforward test at the 5% level is not possible.

sum(dbinom(c(0,1,9,10), 10, .5))
[1] 0.02148437
sum(dbinom(c(0,1,2,8,9,10), 10, .5))
[1] 0.109375


Thus the power to detect as biased a coin with P(H) = 0.3 is only about 15%.

sum(dbinom(c(0,1,9,10), 10, .3))
[1] 0.149452


(b) There are two difficulties with an approximate normal test in this situation. (i) $$n = 10$$ is not quite large enough to guarantee a good approximation to binomial probabilities. (ii) The approximate test may make it appear that a test at the 5% level is possible, but with $$n=10, p=0.5$$ values of $$|Z|$$ near 1.96 are not possible, so the actual significance level is closer to 2% than 5%.

• I understood the Normal approximation way of solving. But I have read that if the sample size is smaller than 30 we should use T-test. In this case what is sample size ? Is it 10 or since the event itself is tossing coin ten times so that makes sample size as 1 ? Commented Jun 12, 2021 at 11:51
• $n = 10$ is at very lower edge of sample sizes that might work with normal approximation. One common rule is that you can use normal approx if $np$ and $n(1-p)$ are both at least five. So for $p=.5$ you just barely meet the criterion. // IMHO, you should always be wary about $n=30$ quoted as sample size limit. Often bogus. // I used normal approx in 1st part of my Answ because I guessed that might be what's expected of you. I used exact binomial in 2nd part because I try to use exact binomial methods when I can. // Most important for you now: understand basics of CIs and hypothesis testing. Commented Jun 14, 2021 at 5:59
• I have hard time understanding what Binomial distribution for this question exactly is ? Is it frequency distribution of hugh collection of no. of heads in 10 tosses of coin ? If it is this then according to the question sample size is 1, right because in question the coin is tossed 10 times. For sample size to reach 30 to use Normal approximation the experiment of tossing coins 10 times and counting head should be repeated 30 times and then and average number of heads in those 30 repetition is lets say 3 then we do the z test and find out whether we can reject null hypothesis or not ? Commented Jun 14, 2021 at 8:49
• If you can help me in this please help me. I am not from statistics background. Commented Jun 14, 2021 at 8:50
• "Not having a statistics background' is not a permanent condition. // If you toss a coin $n = 10$ times and you assume (as in $H_0,)$ that $p = 1/2,$ then the number $X$ of Heads has distribution $\mathsf{Binom}(n-10, p=1/2)$ with PDF $f(x) = {10 \choose x}(1/2)^x(1/2)^{10-x}$ $= {10\choose x}/2^{10},$ for $x = 0, 1, 2, \dots, 10.$ This distribution is approximately $\mathsf{Norm}(\mu = np = 5, \sigma=\sqrt{np(1-p)} = \sqrt{5/2}).$ // For general $p$ in $(0,1)$ you have $X\sim\mathsf{Binom}(n-10, p)$ with PDF $f(x) = {n\choose x}p^x(1-p)^{n-x},$ for $x = 0, 1, 2, \dots, 10.$ Commented Jun 14, 2021 at 13:28

Another way to extract probabilities is to simulate :

Imagine a fair coin.

Toss it 10 times and write down the number of heads.

According to the central limit theorem, the number of heads in 10 tosses will follow a Normal-like distribution with mean

Then do it all over again. And again. And again. N times (maybe N = 1000000 times)

Then calculate the 2.5th and 97.5th percentiles of the distribution of the N simulated number of heads.

Now you toss your real coin ten times and write the number of heads.

If you got less heads than the 2.5th percentile, or more heads than the 97.5th, then you decide that the coin is not fair.

Don't forget that this time when you tossed your real coin 10 times and rejected the hypothesis of the fair coin, could be among the 5% of identical experiments where the result would have been extreme enough to get rejected despite the coin being fair.

The formula to calculate the approximate confidence limits for a binomial test is:

$$z_{alpha/2}*\sqrt{p*q/n}$$

In your case for a fair coin p = q = 0.5 and using $$z_{alpha/2}=1.96$$ for a 95% confidence limit.

The range of heads for 10 flips is expected to be between

$$10*(0.5 \pm 1.96*\sqrt{0.025})$$ or 1.9 to 8.1 heads

with a 95% confidence level.

Or to rearrange to calculate the test statistic:

$$test statistic = \frac{(observed - n*p_{expected})}{\sqrt{n*p*q}}$$

In R use binom.test(5, 10, p=0.5)

The Red Bead experiment and Deming is where I start.

An unfair coin is a special or assignable cause of variation. When should we look for a special cause? When we see something beyond 3 standard deviations.

10 flips might not be enough.

.5 +/- 3 times sqrt of (.5*.5/N), where N is number of flips.

More than ~ 9.743 H or Ts might be worth looking at. But can you have .7 of a head? No. So you should round 9.7 to 10, in which case probably not meaningful to investigate if 10 flips in a row is all you have.

But a better approach might be to assume the coin is unfair and follow Von Neumann who described a procedure like this:

1. Toss the coin twice.
2. If the outcome of both coins is the same (HH or TT), start over and disregard the current toss.
3. If the outcome of both coins is different (HT or TH), take the first coin as the result and forget the second.