Coin toss puzzle Probability is one of my favorite areas in maths, so I always try to devise problems on my own and try to solve them myself, but this one is a real challenge.
Imagine participating in a contest to see how lucky/unlucky you are. The host gives you a fair coin, then tells you to flip is 100 times. If precisely 40 of the flips results in heads, you win a million dollars. What is the probability that you'll win?
This puzzle is what I call the "probabilities of probabilities" which I'm kind of new to. Can someone explain how to calculate the probability step-by-step? Thanks.
 A: Suppose exactly $40$ filps resulted in heads. From the first toss to the $100$-th toss, there are exactly $40$ places that the $i$-th toss resulted in heads. Thus, the number of ways to choose the $40$ places equals $100 \choose 40$.
For each choice, we calculate the probability and add them all up.
Since each coin toss is independent of each other, each choice has probability of $(0.5)^{40}\cdot (0.5)^{60}$.
Thus, the overall probability is ${100 \choose 40} \cdot 2^{-100} \approx 0.0108$.

This is an example of a binomial distribution. Generally, when we perform $n$ independent trials with probability of success $p$, the probability that we will get exactly $k$ successful trials is equal to
$${n \choose k} p^k (1-k)^{n-k}$$
The ${n \choose k}$ term is for each arrangement of trials (successful/unsuccessful) and $p^k$ is for succeeding $k$ times, $(1-p)^{n-k}$ is for failing ${n-k}$ times.
In the OP's question, $n = 100$, $k = 40$, $p = 0.5$. Plugging in the values will give the answer.
