There seems to be some disagreement on among answers on the internet for the question:

A bag contains 1 fair and 1 double-sided (heads) coin. We choose a coin at random and flip it once. What is the probability of the coin being the double-sided sided one, given the result is heads?

I decided to explore the problem using Python, and came up with the code below. Does the code correctly represent the situation, and is the experimental answer of "roughly two thirds" which it produces correct please?

import random

num_trials = 10000

results = {
    "fair, heads": 0,
    "two-headed, heads": 0

for i in range(num_trials):
    this_coin = random.choice(["fair", "two-headed"])
    if this_coin == "fair":
        if random.choice(["heads", "tails"]) == "heads":
            results["fair, heads"] += 1
        results["two-headed, heads"] += 1
fair_heads =  results["fair, heads"]
double_sided_heads = results["two-headed, heads"]
print("fair, heads: " , fair_heads )
print("two-headed, heads: ", double_sided_heads)
print("experimental probability of two-headed coin given heads:", double_sided_heads, "/", double_sided_heads + fair_heads )
print("experimental probability of two-headed coin given heads:", double_sided_heads/ (double_sided_heads + fair_heads) )
  • $\begingroup$ What alternative might some have been imagining? $\endgroup$
    – Nat
    Commented Mar 20, 2021 at 2:15
  • 2
    $\begingroup$ Some say its 50/50. This doesn't seem entirely unreasonable. There are two coins - I've flipped one of them and it shows heads. So what? It's still one of two coins. I get that this is wrong, but the correct answer isn't obvious, IMO. I think the situation is somewhat analogous to the Monty Hall Problem, which many expert mathematicians were stubbornly wrong about. $\endgroup$ Commented Mar 20, 2021 at 7:41
  • 3
    $\begingroup$ Why count to 4 and be sure you exhaust every possible case, when you can write a python script, loop 10000 times and hope you describe every outcome? :) $\endgroup$ Commented Mar 20, 2021 at 12:30
  • 1
    $\begingroup$ There is a good reason for that - abstraction is often harder to understand than concrete examples, and intuition can be very wrong. Look at the history of the Monty Hall Problem for evidence of this. $\endgroup$ Commented Mar 20, 2021 at 13:25

4 Answers 4


The outcomes are:

  1. Fair coin, $H$

  2. Fair coin, $T$

  3. Unfair coin, $H$

  4. Unfair coin, $H$ (the other one)

Each of these is equally likely, so each has a probability of $1/4$, meaning that $P(\text{H}) = \frac{3}{4}$.

We want to know $ P(\text{Unfair} \vert H) $. This is a job for Bayes' Theorem: $P(B\vert A) = \dfrac{P(A\vert B)P(B)}{P(A)}$.

Our $B$ is the unfair coin, and our $A$ is heads.

$$ P(\text{Unfair} \vert H) = \dfrac{P(H\vert\text{Unfair})P(\text{Unfair})}{P(H)} = \dfrac{1\times \frac{1}{2}}{\frac{3}{4}} = \dfrac{2}{3} $$



I would like to add to @Dave’s excellent answer by stating it in words, as some may find that easier to understand (but it’s no different).

You start with 2 coins, one is double heads, the other is normal. So that’s 4 sides, of which 3 are heads and 1 is tails. Therefore, before you have chosen a coin, your probability of getting a head is 3/4. And your probability of getting the unfair coin is 1/2.

After you have selected a coin and looked at one side to reveal a head, you have now reduced the “in play” possibilities to 3 sides: 2 heads and 1 tail.

Obviously, now the probability the other side is heads = the probability the coin is unfair. Given that, what’s the probability the other side is another head? Well, it must be 2/3.

There are lots of variations on this type of problem, often starting with 3 objects (doors/pancakes/cards) and it’s sometimes more instructive to think of those situations - indeed sometimes it helps to start with 99 unfair coins and 1 fair, and then consider the probabilities.

Richard McElreath has a nice video explaining this in the context of pancake flipping, which is a version of the Monty Hall Problem

  • 1
    $\begingroup$ I'm having trouble following this. I've got two bits of paper, one with H on both sides, one with H on one side and T on the other. I've selected one piece, and it shows H. You wrote "After you have selected a coin and looked at one side to reveal a head, you have now reduced the “in play” possibilities to 3 sides: 2 heads and 1 tail.". What exactly are these possibilities of, and why are there 3 please? $\endgroup$ Commented Mar 19, 2021 at 14:59
  • 2
    $\begingroup$ You started with 4 sides. You looked at one (H). Once you’ve looked at one side you have the information for that side, you’re certain what it is - there’s only 3 remaining sides with any uncertainty, so it’s only these 3 you need consider for forming any probabilities. These are 2 H and 1 T. So probability of H is 2/3. $\endgroup$
    – Mooks
    Commented Mar 19, 2021 at 15:04
  • 1
    $\begingroup$ Some really smart people have been flummoxed by Bayes’ Rule! The key point is to think - what is my state of knowledge right now. What do I know, what do I not know (ie what do I have to assign a probability to)? And then when a new piece of information comes in, you update your state of knowledge in a rigorous way (by Bayes Rule). Think about after you’ve selected a coin and looked at one side, you’ve seen heads. The other side is still unknown so if it’s heads you’re 100 % sure the coin is unfair. If it’s not you’re 100 % sure it isn’t. So at that moment P(heads) = P(unfair). $\endgroup$
    – Mooks
    Commented Mar 19, 2021 at 15:31
  • 3
    $\begingroup$ The way I see it, you've got a bag containing three heads and a tail. You reach in and pull out a head. What's the probability that it's attached to the unfair coin? Well, two out of the three are, so that's your probability: 2/3. $\endgroup$
    – Mark
    Commented Mar 19, 2021 at 22:12
  • 1
    $\begingroup$ +1 for the Monty Hall problem reference. $\endgroup$ Commented Mar 20, 2021 at 22:45

Something else I would add, which might help make the answer a bit clearer: if you pull out a coin and get a tails, you put it back in the bag and start again. This is why the probability is not 50:50, because when you say you've pulled out a heads, you have encountered one of a limited set of outcomes, compared to all of the possible outcomes.

If you pulled a coin out and it was heads or tails, the probability is clearly 50:50. But you know it was heads, so it is now intuitively more likely to have been the unfair coin that was both heads.

  • $\begingroup$ I find this hard to reason about. "If you pulled a coin out and it was heads or tails" doesn't actually make sense to me - it's like Schrodinger's Cat at that stage... $\endgroup$ Commented Mar 20, 2021 at 13:27
  • $\begingroup$ @RobinAndrews If you pulled out a coin and there's no restriction on what you see, that's just pulling out a coin. But given that you saw heads, if you want to model that in the real world, you can make not-heads “try again”, replacing it with a smaller copy of the probabilities of everything else, like a converging series. $\endgroup$
    – wizzwizz4
    Commented Mar 20, 2021 at 23:07

This answer tries to bring together concepts from the other answers, but using clearer words.

When we “choose a coin at random and flip it once”, there are four equally likely outcomes:

  1. Fair coin, tails
  2. Fair coin, heads
  3. Two-headed coin, heads 1
  4. Two-headed coin, heads 2

If we know that the result is heads, we can eliminate the outcome 1, leaving outcomes 2 to 4, which are still equally likely. This gives us three equally likely outcomes, out of which two involve the two-headed coin, so the probability is 2 out of 3.

Your Python code looks perfect, and as long as it uses a good random-number generator and sufficiently many trials, will definitely produce (a good approximation to) the correct answer.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.