# Bayes theorem in a simple example

Having this situation

http://i.stack.imgur.com/PE226.jpg

two urns with the number of balls in there pictured above..

and two events

A = urn is 1 B = ball is white

I know that $P(A) = 1/2$, $P(\text{not }A) = 1/2$, $P(B \mid A) = 2/3$, $P(B\mid\text{not }A) = 3/4$

but if I try to verify the Bayes Theorem with P(B/A), I get troubles..

P(B/A) should be

$$P(B\mid A) = \frac{P(A\mid B)P(B)}{P(A)}$$

$P(B\mid A)$ is $2/3$, $P(A)$ is $1/2$, $P(B)$ I think is $5/7$, but how about $P(A\mid B)$?

Is it meaningful asking for the probability that I choose urn 1 knowing that I extracted a white ball? I think not but I'm unsure... am I asking the probability that the urn was the first known the ball extracted was white?

-
Never ever write Bayes' Theorem as you have done. The correct expression is $$P(B\mid A) = \frac{P(A\mid B)P(B)}{P(A\mid B)P(B)+P(A\mid B^c)P(B^c)}$$ which emphasizes (i) that the numerator is one of the terms in the denominator and (ii) the denominator, which happens to be $P(A)$ in this instance, is something that needs computation. For your problem, you know $P(B\mid A)$ so there in nothing to verify. You can find $P(A\mid B)$ via $$P(A\mid B) = \frac{P(B\mid A)P(A)}{P(B\mid A)P(A)+P(B\mid A^c)P(A^c)}.$$ Don't guess that "$P(B)$ I think is $5/7$", its value is the denominator. –  Dilip Sarwate Dec 21 '11 at 17:10
@DilipSarwate : It doesn't just "happen to be $P(A)$ in this instance"; it will always be $P(A)$. One writes it in the form you have given because one uses this identity in situations where the information one has makes it possible to use that form. –  Michael Hardy Dec 21 '11 at 21:30
@MichaelHardy I am aware that the denominator expression of the first of my displayed equations will always equal $P(A)$, not just in this instance. I was trying to make the point that the denominator of the second of my displayed expressions is $P(B)$ which needs to be computed (rather than guessed at as the OP was doing) and one of the terms in the computation can be reused in the numerator, while the denominator of the first is $P(A)$ which is a given quantity in the OP's problem. Unfortunately, I ran out of both characters and seconds before I could express myself fully. –  Dilip Sarwate Dec 21 '11 at 21:57

I am just discussing the situation and hope that will answer your question.

First of all, I quite disagree with your contention that $P(B)$ is $5/7$. Because, to calculate this, you need to make two cases: the urn chosen was 1 and the urn chosen was not 1, and in each case, consider the probability of getting a white ball.

So, $P(B)$ is $$P(B)=P(A).P(B|A)+ P(\bar A).P(B|\bar A)$$ So, it turns out that $P(B)=\frac{17}{24}$. So, Now you can calculate, $P(A|B)$ using Bayes' Rule, $$P(A|B)=\frac{P(B|A).P(A)}{P(B)}$$ Here, from the information you have provided yourself, we get $P(A|B)=\frac{8}{17}$. So, now see that, the expression you have written down is true.

So, the probability you are asking about, the probability that urn 1 was chosen given a white ball was drawn, is computable and is reasonable to ask. But, note that computation of this fact needs Bayes' Rule.

-
You say "Now you can calculate, $P(A|B)$ using Bayes' Rule again" The word "again" puzzles me. Where did you use Bayes' rule in the first place that you are using it again to get $P(A|B)$? –  Dilip Sarwate Dec 21 '11 at 22:20
@Dilip Fixed, Thanks for the pointer. –  user21436 Dec 22 '11 at 4:43

I can't comment, but the question seems a bit loose. To say it back, you have two urns, $X$ and $Y$, where $X$ has two white balls and one black one and $Y$ has three white balls and one black one.

Now you define events: $A$ is picking urn $X$ and $B$ is getting a white ball.

You are now going to pick an urn uniformly at random and then pick a ball uniformly from the selected urn.

At this point it should be clear that $P(B)$ is not $5/7$. It is actually: $(1/2)(2/3) + (1/2)(3/4) = 17/24$. Now use Bayes rule to get $P(A|B)$, which is otherwise not obvious.

-
you are right, i figured it out thanks to Kannappan –  user21581 Dec 21 '11 at 18:01
It is worthwhile to think about this kind of thing the way a statistician would to get intuition. The urns represent different "models" of an unknown process that produces white and black balls: one with the probability of white $2/3$ and one with $3/4$. At first you have no idea which one it is, so you weight them equally (this is the $P(A) = 1/2$ in your question). Now you let the process show you a ball. If it's white, then you work out that $P(A|B) = 8/17 < 1/2$, so your belief shifts a little away from thinking $X$ is the right model. Then you can update and repeat. –  Louis Dec 22 '11 at 12:17