Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Here is a problem: we have a table with 8 trays. With probability $0.5$, there is a letter somewhere in the table. What is the probability that there is a letter in a last tray, given that there is no letter in first 7 trays?

It looks trivial, but now I'm really confused. Here is how I solved it: let $A$ be the probability that there is a letter in a table (so $P(A) = 0.5$); let $B_i$ be the probability that there is a letter in i-th tray; we need the probability $P(B_8 | \overline{B}_{1-7}) = P(B_8|A\overline{B}_{1-7}) * P(A) + P(B_8|\overline{A}\overline{B}_{1-7}) * P(\overline{A})$. $P(B_8|\overline{A}\overline{B}_{1-7})$ is $0$ (because there is no letter in the table at all), and $P(B_8|A\overline{B}_{1-7})$ is $1$, because we know that the letter is in the table and there is no letter in first 7 trays. So $1*0.5 + 0*0.5 = 0.5$.

But then I've tried a simulation:

#!/usr/bin/python

import random

test_n = 100000

table_empty = [False for x in xrange(8)]

suitable = 0
letter_in_last = 0
for i in xrange(test_n):
    has_letter = random.random() >= 0.5
    table = table_empty[:]
    if has_letter:
        table[random.randint(0,7)] = True

    if any(table[:7]):
        continue # there is a letter in 7 first trays
    else:
        suitable += 1
        if table[-1]:
            letter_in_last +=1

print "made %s tests" % test_n
print "%s haven't a letter in first 7 trays" % suitable
print "%s have a letter in last tray" % letter_in_last
print "probability: %s" % (1.0 * letter_in_last / suitable)

And results are like this:

made 100000 tests
56291 haven't a letter in first 7 trays
6185 have a letter in last tray
probability: 0.109875468547

Where is my mistake?

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

There are 9 possibilities. Either there is no letter anywhere (probability $0.5$), or there is a letter in one specific drawer with uniform probability $\frac{1}{16}$. The fact that the first seven drawers had no letters eliminates seven of the nine options, and we're stuck with No Letter with weight $0.5$, and Letter In Last Drawer with weight $0.0625$. All in all, a $12.5\%$ probability that there is a letter in the last drawer.

Edit: The reasoning here is that once the probabilities are fixed in the beginning of my reasoning, we stop thinking of them as absolute probabilities, and rather as weights. The moment we open an empty drawer, that drawer's weight becomes $0$, but the weight of the other possibilities remains unchanged. The moment we open a drawer with a letter, all other weights becomes $0$. Then the ratio of a weight to the total weight is the probability that the letter is in a specific location (be it a drawer or in non-existence).

share|improve this answer
    
This is a variation on Monty Hall, but in which the game host does not know whether the door he opens is a goat or a car, he just happens to stumble over a goat. The slight variation changes how you calculate the probability. –  Arthur Oct 12 '12 at 8:59
add comment

Your equation $P(B_8 | \overline{B}_{1-7}) = P(B_8|A\overline{B}_{1-7}) P(A) + P(B_8|\overline{A}\overline{B}_{1-7}) P(\overline{A})$ is wrong. The left-hand side is conditioned on $\overline{B}_{1-7}$, and this condition is missing in $P(A)$ and $P(\overline{A})$. The correct equation is $P(B_8 | \overline{B}_{1-7}) = P(B_8|A\overline{B}_{1-7}) P(A| \overline{B}_{1-7}) + P(B_8|\overline{A}\overline{B}_{1-7}) P(\overline{A}| \overline{B}_{1-7})$, but that's not very useful for solving the problem since we don't know $P(A| \overline{B}_{1-7})$ and $P(\overline{A}| \overline{B}_{1-7})$.

Arthur has already posted a correct solution, so I'll leave it at that.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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