Flip some coins

If you toss 1 coin 10 times, what is the probability that it will come up Heads for all tosses?

If you compute this, you have ( 1 2 * 1 2 ... * 1 2 ) 10 times. That is about 0.1%.

Now, there is not only you who does the experiment but 1000 persons for example. What is the probability that at least one of the coins will come up all heads?

If you compute this you have: 1 - ( 1 - 1 2 10 ) 1000 That is about 63.%

We can generalize this as follows. N persons flip a coin M times.

1 - ( 1 - 1 2 M ) N

How does this function behaves when we increment the number of persons that run this experiment?
I ran the experiment with M fixed at 10.

About this lab

Inspired by Lecture 2 of Caltech Machine Learning course.
Use MathJax for the formulas.
Use d3.js to build the plot.
Plot inspired by Line Chart example
Use a simple python function for the data.

M = 10
MAX_COINS = 10000

def toss(N, M):
    return 1 - (1 - 1./(2.**M))**N

def lab():
    return [toss(N,M) for N in range(MAX_COINS)]
    

comments powered by Disqus