Imagine you have a bag of 10 coins. 9 of them are fair, and 1 is biased. The biased coin has a 75% chance of landing on heads. If you draw a coin from the bag, flip it 5 times, and get 5 heads in a row, how confident should you be that you have the biased coin?

#### Solution

Imagine you had all 10 coins and flipped them 5 times each. You repeat this thousands of times. You would get a bunch of outcomes. HHTHT, TTHTT, and so on where H = heads and T = tails. Some would also be HHHHH.

A fair coin has a 50% chance of landing on heads or tails. A fair coin flipped n times has a (0.5^n) chance of getting all heads. Likewise, our biased coin flipped n times has a (0.75^n) chance of getting all heads.

To find the probability of anything other than all heads, simply note that 'all heads + anything else = 1'. For the fair coin then, there's a 1 - (0.5^n) chance of getting anything other than all heads and that chance is 1 - (0.75^n) for the biased coin.

A fair coin has a 50% chance of landing on heads or tails. A fair coin flipped n times has a (0.5^n) chance of getting all heads. Likewise, our biased coin flipped n times has a (0.75^n) chance of getting all heads.

To find the probability of anything other than all heads, simply note that 'all heads + anything else = 1'. For the fair coin then, there's a 1 - (0.5^n) chance of getting anything other than all heads and that chance is 1 - (0.75^n) for the biased coin.

Imagine you flip all 10 coins 1000 times. You'll have 4 types of outcomes described by the following table:

fair coins | biased coins | |
---|---|---|

not HHHHH | 1000*9*(1 - 0.5^5) | 1000*(1 - 0.75^5) |

HHHHH | 1000*9*(0.5^5) | 1000*(0.75^5) |

Plugging that into a calculator, it's:

fair coins | biased coins | |
---|---|---|

not HHHHH | 8718.75 | 762.70 |

HHHHH | 281.25 | 237.30 |

Now...you take a random trial and find that it was all heads (HHHHH). Was that from a biased coin or a fair coin? There were 281.25 fair coins and 237.30 biased coins that yielded an HHHHH result. (237.30) / (281.25 + 237.30), or ~46% of the HHHHH results were from biased coins.

Knowing that outcome from a huge number of trials, you know that from 1 trial, getting HHHHH from a random coin means your confidence should be ~46% that it's the biased coin.

Walking back through where those numbers came from, the probability of the biased coin given n flips when you have m fair coins for every biased coin is:

**probability of biased coin = (0.75^n)/(0.75^n + m*(0.5^n))**

#### Related problems

How many heads in a row would you need to have 99% confidence? You know it has to be more than 5 since 5 only gave 46% confidence. Trying 10, that yields 86% confidence. Trying 15 yields 98%. 17 ends up being the first n that gives a result greater than 99%.Even with the biased coin landing on heads 75% of the time, you still need 17 heads in a row to be 99% sure you have the biased coin.

What if there are only two coins in the bag...one fair and one biased? Doing the same analysis, you end up needing 12 heads in a row to be 99% confident that you have the biased coin.

Going back to the first one...imagine you grab a coin from the bag, flip it 5 times, and get HHHHH. Then you draw another coin from the bag. What are the odds that the second coin lands on heads when you flip it?

There are two possibilities:

- first coin was biased
- first coin was fair

If the first coin was biased, the next coin has to be fair since there was only one biased coin, so the probability of heads is 0.5. If the first coin was fair, there's a 8/9 chance of getting a fair coin next and a 1/9 chance of getting the biased coin since there are 9 coins left and 1 is biased. In that case, you have a (8/9)*(0.5) + (1/9)*(0.75) chance of getting heads.

From the initial problem, you know there's a 46% chance that the first coin was biased since you got HHHHH from it. That means there's a 46% chance first coin was biased and 54% chance it was fair. Combining all of that:

From the initial problem, you know there's a 46% chance that the first coin was biased since you got HHHHH from it. That means there's a 46% chance first coin was biased and 54% chance it was fair. Combining all of that:

**chance of heads on second coin = 0.46*0.5 + 0.54*((8/9)*(0.5) + (1/9)*(0.75))**

Plugging that into a calculator, you get a ~51.5% chance of heads on the second coin's flip.

## 0 comments:

## Post a Comment