# Average bias of coin factory

A common example in statistics is to estimate the bias of a coin (the proportion of tosses that land "heads"). We can work this out by tossing the coin $N$ times and observing $H$ heads.

The bias (the expected proportion of heads) can be estimated as $\mu = \frac{H}{N}$, which is the mean value if we treat each "heads" result as $1$ and each "tails" as $0$. The standard deviation is $\sigma = \sqrt{\frac{H\times(N-H)}{N}}$

I'm wondering what happens if we "go up a level" to talk about the bias of a coin factory. Let's say a coin factory produces a set of coins $C$: the bias $\mu_c$ of each coin $c \in C$ is constant (but unknown) across all the tosses of that coin; the biases of different coins may vary, due to stochastic processes in the factory's production line.

We want to estimate the mean and standard deviation of coins produced by the factory, based on observations of the coins $C$ it has previously produced. For each $c \in C$, we have observed $H_c$ heads occur in $N_c$ tosses (these may both differ between coins).

Here's my approach to solving this:

To combine the estimates from each coin, we might think about using the ratio of the averages (RoA):

$$RoA = \frac{\sum_{c \in C}{H_c}}{\sum_{c \in C}{N_c}}$$

RoA would be appropriate if the biases of each toss were independent (so grouping them per coin is unnecessary), or to answer a question like "how much influence has the factory's bias had on our bets" (in some hypothetical coin-tossing casino).

For this question RoA seems inappropriate, since each coin acts like a single sample of the factory; if some $c$ has larger $H_c$ and $N_c$ values it tells us more about that coin, but doesn't alter how representative the coin is of the factory.

I think the best method is to just take the average of the ratios (AoR):

$$AoR = \frac{\sum_{c \in C}{\mu_c}}{|C|} = \frac{\sum_{c \in C}{\frac{H_c}{N_c}}}{|C|}$$

However, I don't know how we'd estimate the standard deviation for this, e.g. whether to combine those of the coins in some way, or whether to go down to the level of the tosses.

• To do this precisely will require some assumptions about the distributions of the coins. You can estimate the means with a weighted average of the individual coins; the weighting will be the number of each coin manufactured. And you can also say fairly safely that you want an UNBIASED estimator of the bias - as a biased estimator of bias would be pointless. Assuming the bias is small (i.e. the coins are pretty fair) you can assume it's a normal distribution and not worry too much about your estimator being biased. Commented Nov 13, 2017 at 17:32
• The sum of two independent normally distributed random variables is normal, with its mean being the sum of the two means, and its variance being the sum of the two variances (i.e., the square of the standard deviation is the sum of the squares of the standard deviations.) So that should make a good method fairly straightforward. Commented Nov 13, 2017 at 17:32
• I think there's a step missing: in my phrasing $N_c$ is the number of times coin $c$ was tossed, yet you say "the number of each coin manufactured". Would I be right in guess that you first replaced "$N_c$ tosses" with "$N_c$ identical copies, each tossed once"? Commented Nov 13, 2017 at 18:28
• To work out the bias of the factory you need to know how many of each coin it made. If it makes a run of 99 million one dollar coins which are perfectly weighted, and a run of 1 million quarters which are biased then in assessing the bias of the factory the bias of the quarters must be assigned only 1% weight compared with 99% weight assigned to the zero-biased dollars. Commented Nov 13, 2017 at 18:33
• More on the Bayesian approach: The single coin "implements" a binomial distribution with unknown parameter $p$, and we represent our uncertainty about $p$ using a beta distribution with parameters $\alpha,\beta$; as we flip the coin, we update $\alpha,\beta$ to model our updated knowledge about $p$. Going "up a level", we might model the coin factory as "implementing" a beta distribution with unknown parameters $\alpha,\beta$ (describing the distribution over coin true biases that the factory produces) and would then need other distributions to model our uncertainty about those parameters.
– Karl
Commented Dec 13, 2022 at 23:09