# Using Binomial coefficient to solve a problem with unfair coins

I have 5 fair coins and 10 unfair coins in a bag. For the unfair coins, there is 80% chance of getting a head and 20% for tails. What's the probability of flipping 4 heads out of 6 flips? Each flip is with a different coin, and there is no replacement.

I came up with two different answers using two approaches.

Approach # 1:

Probability of getting a head regardless of fair or unfair coin $$(5/15) \cdot 0.5 + (10/15) \cdot 0.8 = 0.7$$

Probability of flipping 4 heads out of 6 flips $$\frac{6!}{4!2!} \cdot 0.7^4 \cdot 0.3^2 = 0.324135$$

Approach # 2:

Probability of getting 4 heads out of 6 flips in fair coin $$\frac{6!}{4!2!} \cdot 0.5^6 = 0.23438$$

Probability of getting 4 head out of 6 flips in unfair coin $$\frac{6!}{4!2!} \cdot 0.8^4 \cdot 0.2^2 = 0.24576$$

Probability of getting 4 heads out of 6 flips $$(5/15) \cdot 0.23438 + (10/15) \cdot 0.24576 = 0.24197$$

Which approach is the correct one? What was the flaw / misstep in the wrong approach? Thanks!

• Do you pick a different coin on each flip? Is there replacement? We need more details to help. – ml0105 Jan 6 '15 at 3:37
• Just updated the question: Each flip is with a different coin and there is no replacement. – user1848902 Jan 6 '15 at 3:43
• Neither approach seems to be justified. The only thing I can think of immediately is a painful cases calculation. – André Nicolas Jan 6 '15 at 3:51

Your approaches do not take into account that the probabilities of drawing an unfair or fair coin do vary from step to step. As André Nicolas points out, there is no direct analytical way to calculate the overall probability.

I have tried to determine the probability experimentally with the following C# code:

using System;

namespace akCoins
{
class Bag
{
int fairCoins;
int unfairCoins;
Random r = new Random();

public void init(int f, int u)
{
fairCoins = f;
unfairCoins = u;
}

{
int x = r.Next(1, fairCoins + unfairCoins);
bool fair = (x <= fairCoins);

fairCoins   -= fair ? 1 : 0;
unfairCoins -= fair ? 0 : 1;

x = r.Next(1, 10000);

return x <= (fair ? 5000 : 8000);
}
}

class Program
{
static void Main(string[] args)
{
int trueCount = 0;
int totalCount = 0;
Bag bag = new Bag();

for (int itera = 0; itera < 100000000; itera++)
{

bag.init(5, 10);
for (int i = 1; i <= 6; i++)
{
}

trueCount += (heads == 4) ? 1 : 0;
totalCount++;
}

+ (100.0 * trueCount) / totalCount + "%");
}
}
}


The resulting probability of 4 heads out of 6 is 33.38%

Strangely enough, in spite of the high number of 100 million iterations, I get slightly varyiing results (33.38% +/- 0.005%) when I repeat the experiment.

When modifying the coin flipping experiment from random number generator thresholds [1...5000...8000...10000] to [1...5...8...10] the resulting probability goes down to 28.8%. I am not sure, why.

• I'm confused. Why do we still need to account for whether the coin drawn is fair or unfair. Didn't we already establish that the probability of flipping a head is 0.7 regardless of whether the coin is fair or not? – user1848902 Jan 6 '15 at 15:03
• If you draw a fair coin first, you increase the percentage of unfair coins remaining in your bag. Therefore, the subsequent probability of head flips is increased. The probability of flipping a head is/remains dependent of the type of coin. – Axel Kemper Jan 6 '15 at 15:10
• Ok. So am I correct to think that 0.7 - the probability of flipping a head - only holds if there is replacement? – user1848902 Jan 6 '15 at 15:18
• Yes. If you always but the coin back into the bag after flipping, the coin mixture and thus the flipping probability stay constant. – Axel Kemper Jan 6 '15 at 16:24

Consider cases:

You have 15 coins, and you draw 6. These are the 6 possible scenarios:

1 UFFFFF

2 UUFFFF

3 UUUFFF

4 UUUUFF

5 UUUUUF

6 UUUUUU

Compute the probability of each scenario:

P(scenario i) = $\binom{5}{6-i}\binom{10}{i} / \binom{15}{6}$

For each scenario compute the probability of getting 4/6 heads.

For scenario 1, we have two subscenarios: U is heads or U is tails i.e.

1 UFFFFF

a HHHHTT

b THHHHT

P(scenario 1 subscenario a) = $0.8 \binom{5}{3} 0.5^3 0.5^2$

1b is left to you.

Scenario 2 will have 3 subscenarios. Scenario 3 will have 4 subscenarios and so on.

Anyway, the final probability will be

P( 4 out of 6 heads ) =

P(scenario 1)[P(scenario 1 subscenario a) + P(scenario 1 subscenario b)]

+

P(scenario 2)[P(scenario 2 subscenario a) + P(scenario 2 subscenario b) + P(scenario 2 subscenario c)]

• ... +

P(scenario 6)[P(scenario 6 subscenario a) + P(scenario 6 subscenario b) + ... + P(scenario 6 subscenario g)]