# Determine if many coins are fair

Imagine I have many coins ($>100$), and for each coin I have the data: $(n_{\rm heads}, n_{\rm tails})$ where $\sum(n_{\rm heads}, n_{\rm tails})$ is decreasing for each next coin. Any one of the coins can be unfair ($P({\rm head})\ne 0.5$). Some coins might be an exact copy of any other coin, some might not be.

How do I determine all coins are fair?

• Your title doesn't match the question in the body text. Which do you want answered? – Glen_b Apr 11 '14 at 23:48
• Are you more interested in an omnibus test ("do at least some deviate from fairness?") or at identification ("which coins aren't fair?") – Glen_b Apr 12 '14 at 1:50

Let the null hypothesis be that all coins are fair. Then we can pool all the observations together (since they all essentially came from the 'same' fair coin). This will give you a proportion. From here you can do a simple binomial test to check if that proportion is equal to 0.5 or not.

The power of this test might not be so great depending on how sparse the signal is. It was the first thing that came to mind

> x <- c(rbinom(100, 100, 0.5), rbinom(100, 100, 0.45), rbinom(100, 100, 0.65), rbinom(100, 100, 0.3))
> binom.test(sum(x),length(x)*100)

Exact binomial test

data:  sum(x) and length(x) * 100
number of successes = 19168, number of trials = 40000, p-value < 2.2e-16
alternative hypothesis: true probability of success is not equal to 0.5
95 percent confidence interval:
0.4742935 0.4841095
sample estimates:
probability of success
0.4792

>
> x <- c(rbinom(100, 100, 0.5), rbinom(100, 100, 0.5), rbinom(100, 100, 0.5), rbinom(100, 100, 0.45))
> binom.test(sum(x),100*length(x))

Exact binomial test

data:  sum(x) and 100 * length(x)
number of successes = 19507, number of trials = 40000, p-value = 8.426e-07
alternative hypothesis: true probability of success is not equal to 0.5
95 percent confidence interval:
0.4827651 0.4925867
sample estimates:
probability of success
0.487675

• If half the coins are biased toward heads and half toward tails, what happens? What if most are biased up a moderate amount, but some are biased down a lot? More generally, if the average proportion is close to 1/2, even though none of the coins are unbiased, it looks to me like your test would have little power against such alternatives - but those are alternatives that appear to be relevant to the original question. – Glen_b Apr 11 '14 at 23:39
• yeah, I thought about that, this was just the first thing that came to mind. I'm sure we can come up with somethign better. – bdeonovic Apr 12 '14 at 0:18