## DEV Community

Armando C. Santisbon

Posted on

# The Sleeping Beauty Problem

Sleeping Beauty agrees to be the subject of an experiment and is informed of the procedure:

• On Sunday night, she will be put to sleep.
• Then, a fair coin will be flipped.
• If it comes up Heads, she will be awakened on Monday and put back to sleep.
• If it comes up Tails, she will also be awakened on Monday and put back to sleep, but then she'll be awakened on Tuesday as well and put back to sleep.
• Each time that she is put back to sleep she will forget that she was ever awakened.
• Any time she's awake, she will be told no information but she'll be asked one question: What do you believe is the probability that the coin came up heads?

###### Image credit: Veritasium

You might be tempted to say $50\%$ because that's the probability of a fair coin coming up Heads, but you would be mistaken. The correct answer is $1/3$ . To understand why, we need to realize that the question that is really being asked is this: What is the probability that the coin came up Heads given that you've been awakened?

This is a case where we need to incorporate observed data into our prior odds to come up with new odds that account for the new data. To do that, we need to calculate the probability of an event happening given that another event has already happened. We can use Bayes' Theorem for this.

ℹ️ Bayes' Theorem

$P(A|B)={P(B|A)P(A) \over P(B)}$

But wait, where did that come from?

💡 It can be derived from the conditional probability that tells us in how many cases do both events $A$ and $B$ happen out of the cases where $B$ happens:

$P(A|B)={P(A \cap B) \over P(B)}$

Similarly, $P(B|A)={P(A \cap B) \over P(A)}$

which means

$P(A \cap B)=P(B|A)P(A)$

and substituting in the expression for conditional probability yields Bayes' Theorem:

$P(A|B)={P(B|A)P(A) \over P(B)}$

Now that we understand where Bayes' Theorem comes from, there's another way to look at it: As a way to understand two competing hypotheses $H_1$ and $H_2$ . We start by having some prior belief about the odds of those two. After observing some data, what are the new odds of the two hypotheses given the new data? In other words, how do we update our belief based on new evidence?

ℹ️
Let's start by specifying what we mean by odds. We mean how large is one probability relative to the other. Let's put it as a ratio. For example, if prior to seeing any data one hypothesis has $3/4$ probability of being true and the other has $1/4$ :

$\frac {P(H_1)} {P(H_2)}=\frac {3/4} {1/4}=\frac 3 1$

Meaning the odds of $H_1$ to $H_2$ are $3$ to $1$ .

So how do we incorporate the new data $D$ into our belief?

💡 By calculating the new probability of each hypothesis given the new data.

$\frac {P(H_1|D)} {P(H_2|D)}=\frac {\frac {P(H_1 \cap D)} {P(D)}} {\frac {P(H_2 \cap D)} {P(D)}}=\frac {P(H_1 \cap D)} {P(H_2 \cap D)}$

Now we'll use a mathematical trick of multiplying and dividing by the same number to get the same value but expressed in terms of the probability of seeing the observed data given each hypothesis.

$=\frac {P(H_1 \cap D)} {P(H_2 \cap D)} \cdot \frac {P(H_2)} {P(H_1)} \cdot \frac {P(H_1)} {P(H_2)}$
$=\frac {\frac {P(H_1 \cap D)} {P(H_1)}} {\frac {P(H_2 \cap D)} {P(H_2)}} \cdot \frac {P(H_1)} {P(H_2)}$

So,

$\frac {P(H_1|D)} {P(H_2|D)}=\frac {P(D|H_1)} {P(D|H_2)} \cdot \frac {P(H_1)} {P(H_2)}$

And so we have that as a ratio, the posterior odds equal the prior odds times the probabilities of generating the new data.

Now let's apply this to our Sleeping Beauty problem. Let
$H_1=$ The coin came up Heads
$H_2=$ The coin came up Tails
$D=$ You've been woken up

$\frac {P(H_1|D)} {P(H_2|D)}=\frac {1/3} {2/3} \cdot \frac {1/2} {1/2}=3/6=1/2$

Meaning $H_2$ is twice as likely as $H_1$ given the new data. If you want to convert that to probabilities:

$P(H_1)=\frac 1 {1+2}=1/3$
$P(H_2)=\frac 2 {1+2}=2/3$

Therefore Sleeping Beauty should answer that the coin came up Tails as the probabilities are $1/3$ for Heads and $2/3$ for Tails.

We can give another explanation that is more informal but more intuitive. Imagine she's still woken up once if it's Heads, but on $100$ consecutive days if it's Tails. She's awake. She has no idea which of those $101$ scenarios she's in, but effectively she's being asked if she thinks she's in the $1$ scenario where it was Heads or in one of the $100$ scenarios where it was Tails. The answer should be clear.