How to calculate the probability of $3$ heads out of $10$ coins IF each coin has a different probability for head

Let's say

I have $10$ biased coins. Each coin has a different probability for head.

$$\text{coins} = [10\%, 20\%, 30\% ...]$$ I flip each coin once

What is the probability of getting:

1. At least $3$ heads
2. Exactly $3$ heads
• Someone correct me if I'm wrong but could you make a symmetry argument to say that this is equivalent to treating all the coins as having a probability of $\frac{0.1+0.2+...+1}{10}=0.55$ – Remy Dec 15 '17 at 7:14
• @Remy No, that would be incorrect. For example, suppose you have two coins with probabilities of heads being 0 and 1. The result when you toss these coins is not like tossing two coins with probability of heads 1/2. – awkward Dec 15 '17 at 14:36
• @samol make a tree diagram to calculate this! – Ahmed Hossam Jul 25 at 22:16

You can use a probability generating function. If the probability that coin $i$ comes up heads is $p_i$ for $i = 1,2 ,3 \dots ,10$, then the probability that you will get exactly $n$ heads when the ten coins are tossed is the coefficient of $x^n$ in $$\prod_{i=1}^{10} (1 - p_i + p_i x)$$ when the product is expanded. This is easy if you have a computer algebra system but tedious otherwise.

The result when $p_i = 0.1 i$ is $$0.00036288 x^{10}+0.00699984 x^9+0.0482076 x^8+0.159749 x^7+0.28468 x^6+0.28468 x^5 \\+0.159749 x^4+0.0482076 x^3+0.00699984 x^2+0.00036288 x$$ so the probability of exactly three heads is $0.0482076$. For the probability of at least three heads, add the probabilities for one or two heads and subtract from 1. (It is not possible to get zero heads in this example, because $p_{10} = 1$.)

• Can you explain this a little more: For the probability of at least three heads, add the probabilities for one or two heads and subtract from 1. – samol Dec 15 '17 at 18:38
• @samol If $H$ is the total number of heads, $P(H=0)+P(H=1)+P(H=2)+P(H \ge 3) = 1$. Solve for $P(H \ge 3)$. You could also add up the probabilities of 3, 4, 5, ... , 10 heads, but that's more work. – awkward Dec 15 '17 at 20:34

The solution is easy but cumbersome (if I am using the right word). So, I will show the solution for $4$ coins (for the sake of simplicity.) And assume the probabilities to get heads are different: $a,b,c,d$.

If we have $4$ coins then there are 4 possibilities to get exactly $3$ heads and there is one more possibility to get at least $3$ heads as shown below

Accordingly the probability to get exactly $3$ heads is

$$abc+acd+abd+bcd.$$

If we want the "at least" case then we have to add $abcd$.

In the case of $10$ coins the number of possibilities for exactly $3$ heads is ${10 \choose 3}=120$ and all have to be listed like above. In the "at least" case we have much more possibilities to be listed: $\sum_{i=3}^{10} {10\choose i}$ and all have to be depicted.

I wrote some r code to simulate the process of flipping the biased coins. Will 1 million iterations, I found $$p(H=3) \approx 0.0481$$ which agrees nicely with @awkward's answer, and $$p(H\ge 3) \approx 0.992$$

niter <- 1e6 # number of iterations
p <- c(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0) # probabilities

results <- rep(0, niter)

for(i in 1:niter){
trial <- runif(10) < p;
results[i] <- sum(trial);
}

sum(results == 3) / niter # p(H = 3)
sum(results >= 3) / niter # p(H >=3)

hist(results, breaks = c(-1:10)+0.5, freq = FALSE,
main = paste("Histogram of \n",paste(p, collapse = ", "))
)


Here are just some illustration about the calculation process for the "exactly case":

Assume throwing the coin just for $$4$$ times (not for $$10$$ times). There are in total $$\binom{4}{3}=4$$ possiblities for getting a head exactly three times (not $$\binom{10}{3}=120$$ possibilites). The probability for the $$i$$-th coin to be a head is $$p_i^\mathrm{H}=p_i=10i\%=i/10$$. The probability for the $$i$$-th coin to be a tail is $$p_i^\mathrm{T}=1-p_i=1-i/10$$ for each $$1\leq i \leq 10$$.

Each possibility has a different probability and that's what makes the question difficult. The probability for exactly $$3$$ heads can be calculated for this simplified case as:

\begin{align*} p &= p_1^\mathrm{T}~p_2^\mathrm{H}~p_3^\mathrm{H}~p_4^\mathrm{H}~+~p_1^\mathrm{H}~p_2^\mathrm{T}~p_3^\mathrm{H}~p_4^\mathrm{H}~+~p_1^\mathrm{H}~p_2^\mathrm{H}~p_3^\mathrm{T}~p_4^\mathrm{H}~+~p_1^\mathrm{H}~p_2^\mathrm{H}~p_3^\mathrm{H}~p_4^\mathrm{T} \\&= (1-p_1^\mathrm{H})~p_2^\mathrm{H}~p_3^\mathrm{H}~p_4^\mathrm{H}~+~p_1^\mathrm{H}~(1-p_2^\mathrm{H})~p_3^\mathrm{H}~p_4^\mathrm{H}~+~p_1^\mathrm{H}p_2^\mathrm{H}~(1-p_3^\mathrm{H})~p_4^\mathrm{H}~+~p_1^\mathrm{H}~p_2^\mathrm{H}~p_3^\mathrm{H}~(1-p_4^\mathrm{H}) \\&= (1-p_1)~p_2~p_3~p_4~+~p_1~(1-p_2)~p_3~p_4~+~p_1~p_2~(1-p_3)~p_4~+~p_1~p_2~p_3~(1-p_4)\end{align*}

If we were to throw the coin $$10$$ times and ask for the probability of $$3$$ times head, then it's not very different than the case with throwing the coin $$4$$ times. We will just be having $$10$$ levels in the probability tree. Some of the probabilities for the possibilities will look like given below, others will look just as similar, in total we will have to add up the probabilities of all the following probabilities for the $$120$$ possibilities, which of course are not all given, but I think you can imagine

$$120 \text{ probabilities } \begin{cases}p_1~p_2~p_3~(1-p_4)~(1-p_5)~(1-p_6)~(1-p_7)~(1-p_8)~(1-p_9)~(1-p_{10})\\(1-p_1)~p_2~p_3~p_4~(1-p_5)~(1-p_6)~(1-p_7)~(1-p_8)~(1-p_9)~(1-p_{10})\\\hspace{6.5cm}\vdots\\ (1-p_1)~(1-p_2)~(1-p_3)~(1-p_4)~(1-p_5)~(1-p_6)~(1-p_7)~p_8~p_9~p_{10}\\\hspace{6.5cm}\vdots\\ p_1~(1-p_2)~(1-p_3)~(1-p_4)~(1-p_5)~p_6~(1-p_7)~(1-p_8)~(1-p_9)~p_{10}\\ (1-p_1)~(1-p_2)~p_3~(1-p_4)~(1-p_5)~p_6~(1-p_7)~p_8~(1-p_9)~(1-p_{10})\\(1-p_1)~p_2~(1-p_3)~(1-p_4)~p_5~(1-p_6)~(1-p_7)~(1-p_8)~p_9~(1-p_{10})\\\hspace{6.5cm}\vdots \end{cases}$$

Maybe there is a closed formula for the sum of all these $$120$$ probabilities. I would go for programming this.