Processing math: 100%

Tuesday, July 29, 2014

Conditional Probabilities in "Thinking Fast and Slow"

I'm currently reading Thinking Fast and Slow by Daniel Kahneman. (Thanks to Elianna for letting me borrow it.) I'm not finished yet, but 60% of the way through I definitely recommend it.

While reading the "Causes Trump Statistics" chapter (number 16), there is a description of a study about cabs and hit-and-run accidents. It describes a scenario where participants are told that 85% of cabs are Green, 15% are Blue and a given observer has an 80% chance of correctly identifying the color of a given cab. Given this data, the chapter presents a scenario where a bystander identifies a cab in an accident as Blue and Kahneman goes on to explain how we fail to take the data into consideration. I really enjoyed this chapter, but won't wreck the book for you.

Instead, I want to do some math (big surprise, I know). However, I want to make it accessible to non-mathematicians (atypical for my posts).

Given the data, Kahneman tells us that the true probability that the cab was Blue is 41% though we likely bias our thinking towards the 80% probability of the identification being correct. I was on the bus and it kept bothering me, to the point that I couldn't continue reading. Eventually I figured it out (when I got to the train) and I wanted to explain how this is computed using Bayes' Law. As a primer, I wrote a post using layman's terms explaining how we use Bayes' Law. (There is some notation introduced but I hope it isn't too confusing.)

Putting Bayes' Law to Use

We need to understand what 41% even corresponds to before we can compute it. What's actually happened is that we know the event IDB has occurred -- the cab has been identified (ID) as Blue (B). What we want is the probability that the cab is Blue given we know it has been identified -- we want:
Pr(BIDB). Using Bayes' Law, we can write
Pr(BIDB)=Pr(B and IDB both occur)Pr(IDB)andPr(IDBB)=Pr(B and IDB both occur)Pr(B). We're told that a cab can be correctly identified 80% of the time hence
Pr(IDBB)=0.8 (i.e. the probability of correct ID as Blue given it is actually Blue). We're also told that 15% of the cabs are Blue hence
Pr(B)=0.15. We can combine these with the second application of Bayes' Law above to show that
Pr(B and IDB both occur)=Pr(IDBB)Pr(B)=0.80.15=0.12. The only piece of data missing now to finish our computation is Pr(IDB).

Using the extended form of Bayes' Law, since we know that the events B and G (the cab is Blue or Green) are exclusive and cover all possibilities for the cab, we can say that
Pr(IDB)=Pr(IDBB)Pr(B)+Pr(IDBG)Pr(G). Since there is only an 80% chance of correct identification, we know that Pr(IDBG)=0.2 (the probability of misidentifying a Green cab as Blue). We also know that 85% of the cabs are Green hence we can plug these in (along with numbers already computed) to get
Pr(IDB)=0.80.15+0.20.85=0.12+0.17=0.29. Putting it all together we get our answer
Pr(BIDB)=Pr(B and IDB both occur)Pr(IDB)=0.120.29=12290.413793103. Fantastic! Now we can get back to reading...

Bayes' Law Primer

I'm currently writing a blog post that uses Bayes' Law but don't want to muddy the post with a review in layman's terms. So I have something to link, here is a short description and a chance to flex my teaching muscles before the school year starts.

Bayes' Law

For those who aren't sure, Bayes' Law tells us that the probability event X occurs given we know that event Y has occurred can easily be computed. It is written as Pr(XY) and the vertical bar is meant like the word "given", in other words, the event X is distinct from the event XY (X given Y). Bayes' law, states that
Pr(XY)=Pr(X and Y both occur)Pr(Y).
This effectively is a re-scaling of the events by the total probability of the given event: Pr(Y).

For example, if X is the event that a 3 is rolled on a fair die and Y is the event that the roll is odd. We know of course that Pr(Y)=12 since half of the rolls are odd. The event X and Y both occur in this case is the same as X since the roll can only be 3 is the roll is odd. Thus
Pr(X and Y both occur)=16
and we can compute the conditional probability
Pr(XY)=1612=13.
As we expect, one out of every three odd rolls is a 3.

Bayes' Law Extended Form

Instead of considering a single event Y, we can consider a range of n possible events Y1,Y2,,Yn that may occur. We require that one of these Y-events must occur and that they cover all possible events that could occur. For example Y1 is the event that H2O is vapor, Y2 is the event that H2O is water andY3 is the event that H2O is ice.

In such a case we know that since the Y-events are distinct
Pr(X)=Pr(X and Y1 both occur)+Pr(X and Y2 both occur)+Pr(X and Y3 both occur).
Using Bayes' law, we can reinterpret as
Pr(X and Yj both occur)=Pr(XYj)Pr(Yj)
and the above becomes
Pr(X)=Pr(XY1)Pr(Y1)+Pr(XY2)Pr(Y2)+Pr(XY3)Pr(Y3).
The same is true if we replace 3 with an arbitrary number of events n.