# Today I Learned

Some of the things I've learned every day since Oct 10, 2016

## 7: Simulating a Fair Coin Toss

Given an ‘unfair’ coin where $P \textrm{(heads)} = p \neq .5$, we can still use this coin to simulate a fair coin toss.

How?

In order to simulate a fair coin toss, we just need 2 events which are mutually exclusive and equally probable. Examining the probability of different outcomes when flipping our coin twice, we see that

$P(\textrm{heads, heads}) = p^2$

$P(\textrm{heads, tails}) = p(1-p)$

$P(\textrm{tails, heads}) = (1-p)p$

$P(\textrm{tails, tails}) = (1-p)^2$

and notice that $P(\textrm{heads, tails}) = P(\textrm{tails, heads})$. These 2 events are both equally likely and mutually exclusive, so they are exactly what we need to simulate a fair coin toss.

For example, our simulation could go as follows: We repeatedly flip the coin 2 times consecutively until we get a pair of results which are different, ignoring pairs which are the same. If the second result is a heads, we consider it to be as a heads from a fair coin toss, and likewise for tails.