class: center, middle, inverse, title-slide .title[ # Bayes’ theorem ] .subtitle[ ## How To Think - Weeks 12 and 13 ] .author[ ### Fernando Alvear ] .institute[ ### University of Missouri ] .date[ ### Apr 10 and Apr 17 ] --- <script type="text/x-mathjax-config"> MathJax.Hub.Config({ TeX: { Macros: { And: "{\\mathop{\\&}}", Not: "{\\sim}" } } }); </script> # Probabilistic reasoning - Inductive strength (version 1) - Probability - Three main axioms - Probabilistic independence - Mutually exclusive events - Probability of conjunction - Probability of disjunction - Probability of negation - The gambler's fallacy - Independence and inductive strength - Inductive strength (version 2) - Conditional probability - Probability of conjunction with dependent events - Definition of conditional probability - Bayes' theorem - Motivating exercises - Probabilities vs. odds - Prior, strength of evidence, posterior - Base rate fallacy --- # Probability of negation What is `\(P(A \vee \Not A)\)`? `\(A\)` and `\(\Not A\)` are mutually exclusive events, so: `$$\begin{aligned} P(A \vee \Not A) &= P(A) + P(\Not A) \end{aligned}$$` But also `\(P(A \vee \Not A) = 1\)`, so: `$$\begin{aligned} P(A) + P(\Not A) &= 1 \\ P(\Not A) &= 1 - P(A)\end{aligned}$$` .shadow[ .emphasis[ **Probability of negation**:<br> If `\(A\)` is a proposition, `\(P(A \vee \Not A) = 1 - P(A)\)` ] ] --- # Inductive strength (version 1) In deductive logic, we evaluated validity by answering the following question: > Assumming that the premises are true, is the conclusion true? We might evaluate the strength of an inductive argument by answering this other question: > Assumming that the premises are true, is the conclusion highly _probable_? .shadow[ .emphasis[ __Argument strength (version 1)__: An argument with premise `\(E\)` and conclusion `\(H\)` is strong if `\(P(H|E)\)` (the probability of `\(H\)` given `\(E\)`) is high. ] ] - What is conditional probability? - What does it mean that `\(P(H|E)\)` is high? --- # Independence and inductive strength When the premises (evidence) are probabilistically independent of the conclusion (hypothesis), we have a bad inductive argument. 1. `\(E\)`: My wife's family has had nine girls in a row. 2. Therefore `\(H\)`: The next baby in the family will be a boy. Since `\(E\)` and `\(H\)` are independent (the truth of `\(E\)` doesn't make `\(H\)` more or less likely), then `\(E\)` provides no support for `\(H\)`. --- # Inductive strength (version 2) In good inductive arguments, the premises should make the conclusion _more probable_. 1. `\(E\)`: In a recent poll, 99% of people said they will vote for James as the next mayor. 2. Therefore `\(H\)`: James will be the next mayor. In this case, the propositions are dependent, in the sense that the truth of the evidence increases the probability of the conclusion. In a sense, `\(E\)` and `\(H\)` are probabilistically _connected_. This means that `\(E\)` does provide some degree of support for `\(H\)`. .shadow[ .emphasis[ __Argument strength (version 2)__: An argument with premise `\(E\)` and conclusion `\(H\)` is strong if `\(P(H|E) > P(H)\)`, that is, if the probability of `\(H\)` _increases_ after learned `\(E\)`. ] ] How to calculate `\(P(H|E)\)`? With **Bayes' theorem**! --- # Back to multiplying probabilities What is the probability of drawing the two of spade and then the king of hearts (with replacement)? `$$\begin{aligned} P(2\spadesuit \And K \heartsuit) &= P(2\spadesuit) \times P(K\heartsuit) \\ &= 1/52 \times 1/52 = 1/2704 = 0.00037... \end{aligned}$$` What is the probability of drawing the two of spade and then the king of hearts (_without_ replacement)? Notice that these events are not independent (the occurrence of the first event changes the probability of the second event). `$$\begin{aligned} P(2\spadesuit \And K \heartsuit) &= P(2\spadesuit) \times \boldsymbol{P(K \heartsuit |2\spadesuit)} \\ &= 1/52 \times 1/51 = 1/2652 = 0.00038... \end{aligned}$$` `\(P(K \heartsuit |2\spadesuit)\)`: Probability of drawing the king of hearts, **given that** the two of spades has been drawn (and kept outside the deck). --- # Probability of conjunction v2 .shadow[ .emphasis[ **Probability of conjunction**: <br> If `\(A\)` and `\(B\)` are ~~independent~~ propositions, `$$\begin{aligned} P(A \And B) = P(A) \times \boldsymbol{P(B|A)} \end{aligned}$$` ] ] Since the order of the conjuncts is irrelevant, it's also true that `\(P(A \And B) = P(B) \times P(A|B)\)`. According to the definition of independence, if `\(A\)` and `\(B\)` are independent, the occurrence of `\(B\)` doesn't influence the probability of `\(A\)`. <br> Thus, when `\(A\)` and `\(B\)` are independent, `\(P(A|B) = P(A)\)`. .shadow[ .emphasis[ **Independence**: <br> `\(A\)` is independent of `\(B\)` if `\(P(A|B) = P(A)\)`. ] ] --- # Conditional probability In addition, this allows us to define conditional probability: `$$\begin{aligned}P(A \And B) &= P(B) \times P(A|B) \\ P(A|B) &= \frac{P(A \And B)}{P(B)} \end{aligned}$$` .shadow[ .emphasis[ As long as `\(P(B) > 0\)`, the **conditional probability** of A given B is defined by: `$$\begin{aligned} P(A|B) &= \frac{P(A \And B)}{P(B)} \end{aligned}$$` ] ] --- # Conditional probability: intuition When we see a conditional probability of the form `\(P(A|B)\)`, we want to know the probability of A, but focusing only on the occurrence of A when B is the case. Suppose I throw a six-sided die without showing you the result. I tell you that it fell even. What's the probability that it fell on 6? .center[ <img src="assets/conditional-die.jpeg" alt="" height="350"/> ] --- # Checkpoint - In good inductive arguments, the premises should make the conclusion _more probable_. - Argument strength (version 2): An argument with premise `\(E\)` and conclusion `\(H\)` is strong if `\(P(H|E) > P(H)\)`, that is, if the probability of `\(H\)` _increases_ after learned `\(E\)`. - Conditional probability: Probability of an event, given that another event occurred. Now we will learn Bayes' Theorem, which will help us to make sense of `\(P(H|E)\)` and `\(P(H)\)`. .center[ <img src="assets/amazing-thomas-bayes.jpg" alt="" height="250"/> ] --- # Bayes' theorem, motivating exercise Suppose there are two urns of colored marbles. - Urn `\(A\)` contains 8 red balls, 2 green. - Urn `\(B\)` contains 6 green balls, 4 red. I will draw a ball from an urn (I pick it by tossing a fair coin). I will tell you the color, and you will guess which urn I drew it from. > I drew a ball, and it's red `\(R\)`. From which urn I was most likely to have drawn from? .center[ <img src="assets/urns.jpeg" alt="" height="300"/> ] --- It seems more likely that I drew from urn `\(A\)`, as it contains more red balls than green balls. But let's confirm this intuition by calculating the probability that the ball came from urn `\(A\)` given that it was red, and comparing it to the probability that the ball came from urn `\(B\)` given that it was red. > In other words, our intuition says that `\(P(A|R) > P(B|R)\)`. To confirm this, we should calculate these conditional probabilities. .center[ <img src="assets/urns.jpeg" alt="" height="250"/> ] From what we know so far, we can calculate the following: - Probability of drawing from a specific urn: `\(P(A) = P(B) = 1/2 = 0.5\)` - Probability of drawing a red ball from urn `\(A\)`: `\(P(R|A) = 8/10 = 0.8\)` - Probability of drawing a red ball from urn `\(B\)`: `\(P(R|B) = 4/10 = 0.4\)` - Probability of drawing a red ball: `\(P(R) = 12/20 = 0.6\)` --- According to the definition of conditional probability: `$$\begin{aligned} P(A|R) &= \frac{P(A \And R)}{P(R)} \end{aligned}$$` We already know the denominator: `\(P(R) = 0.6\)`. Let's calculate the numerator. `$$\begin{aligned} P(A \And R) &= P(A) \times P(R|A) \\ &= 0.5 \times 0.8 \\ &= 0.4 \end{aligned}$$` `$$\begin{aligned} P(A|R) = \frac{P(A \And R)}{P(R)} = \frac{0.4}{0.6} = \frac{2}{3} = 0.666... \end{aligned}$$` Thus, the probability of drawing from urn `\(A\)`, _having drawn_ a red ball, is 0.666... --- What's the probability of drawing from urn `\(B\)`, _having drawn_ a red ball? `$$\begin{aligned} P(B|R) &= \frac{P(B \And R)}{P(R)} \end{aligned}$$` `$$\begin{aligned} P(B \And R) &= P(B) \times P(R|B) \\ &= 0.5 \times 0.4 \\ &= 0.2 \end{aligned}$$` `$$\begin{aligned} P(B|R) = \frac{P(B \And R)}{P(R)} = \frac{0.2}{0.6} = \frac{1}{3} = 0.333... \end{aligned}$$` --- # Summary of the exercise - We wanted to know the probability of having drawn from a specific urn, given that we learned some information about the color of the ball. - Probability of a hypothesis given evidence. - We also used information about the experimental set up (distribution of green and red balls on each urn). - In our case, given a red ball, it's more likely that it came from urn `\(A\)`. Of course, this doesn't mean that it really came from urn `\(A\)`. I might have been lucky and grabbed a red ball from the four that were in urn `\(B\)`. .center[ <img src="assets/urns.jpeg" alt="" height="250"/> ] --- # Bayes' theorem .shadow[ .emphasis[ **Bayes' Theorem**:<br> `$$\begin{aligned} P(A|B) &= \frac{P(A) \times P(B|A)}{P(B)} \end{aligned}$$` ] ] In the previous exercise we used Bayes' theorem without knowing it! In particular, we calculated `\(P(A|R)\)` using `\(P(R|A)\)`, `\(P(A)\)`, and `\(P(R)\)`. `$$\begin{aligned} P(A|R) &= \frac{P(A) \times P(R|A)}{P(R)} \\ &= \frac{0.5 \times 0.8}{0.6} \\ &= \frac{0.4}{0.6} = \frac{2}{3} = 0.666... \end{aligned}$$` --- # Rev. Thomas Bayes .center[ <img src="assets/amazing-thomas-bayes.jpg" alt="" width="600"/> ] This theorem is named after the philosopher and statistician the Rev. Thomas Bayes (c. 1701–1761). His presentation of the theorem appeared in 1763 (Bayes & Price, 1763). --- # Bayes' theorem (odds version) .shadow[ .emphasis[ **Bayes' Theorem**:<br> `$$\begin{aligned} P(H|E) &= \frac{P(H) \times P(E|H)}{P(E)} \end{aligned}$$` ] ] This form of Bayes' theorem is better for our purposes: .shadow[ .emphasis[ **Bayes' Theorem (odds form)**:<br> `$$\begin{aligned} \frac{P(H)}{P(\Not H)} \times \frac{P(E|H)}{P(E|\Not H)} = \frac{P(H|E)}{P(\Not H|E)} \end{aligned}$$` ] ] This is the form of Bayes' theorem that we will use to evaluate inductive arguments. But why is this version better? --- # Odds Odds are a tool for expressing _relative_ chances. If the odds of a tree in a forest being sick versus healthy are 2:3, it means that there are 2 sick trees for every 3 healthy trees. In a fair coin, the odds of heads versus tails are 50:50 (or 1:1). For every toss resulting in head, there should be one result tails. **Conversion: From probability to odds** Suppose you know `\(P(A)\)`. Then `\(O(A)\)` (the odds of `\(A\)` vs. `\(\Not A\)`) are $$O(A) = P(A):P(\Not A) = P(A):1-P(A) $$ Mathematically, odds are ratios, so it's okay to write them like this too: `$$O(A) = \frac{P(A)}{P(\Not A)} = \frac{P(A)}{1-P(\Not A)}$$` Example: Suppose the probability that Chile will win the next world cup is .01 What are the odds that Chile will win (vs. Chile will not win)? Odds that Chile will win the world cup = `\(0.01:0.99\)`, or `\(1:99\)`, or `\(\frac{1}{99}\)`. 🇨🇱 😭 --- **Conversion: From odds to probability:** Suppose you know that `\(O(A)\)` (the odds of `\(A\)` vs. `\(\Not A\)`) are a:b. Then, `$$P(A) = \frac{a}{a+b}$$` Example: Suppose that the odds of getting a disease are 1 to 1000. What is the probability of getting that disease? `$$P(A) = \frac{1}{1+1000} = \frac{1}{1001}$$` --- # Intuition behind Bayes' theorem `$$\begin{aligned} \underbrace{\frac{P(H)}{P(\Not H)}}_\text{Prior odds} \times \underbrace{\frac{P(E|H)}{P(E|\Not H)}}_\text{Strength of evidence} = \underbrace{\frac{P(H|E)}{P(\Not H|E)}}_\text{Posterior odds} \end{aligned}$$` - Prior odds: Odds of `\(H\)` versus `\(\Not H\)` _before_ learning `\(E\)`. - Strength of evidence: Measure of how much the evidence supports the hypothesis. - Posterior odds: Odds of `\(H\)` versus `\(\Not H\)` _after_ learning `\(E\)`. Bayes' theorem allows us to calculate the odds of a hypothesis after learning the evidence (the _posterior_), by multiplying the odds of the hypothesis before learning the evidence (the _prior_) to the strength of the evidence. In other words: `$$\begin{aligned} \text{Prior odds} \times \text{strength of evidence} = \text{posterior odds} \end{aligned}$$` --- You can write Bayes' Theorem like this: `$$\begin{aligned} \underbrace{P(H):P(\Not H)}_\text{Prior odds} \times \underbrace{\frac{P(E|H)}{P(E|\Not H)}}_\text{Strength of evidence} = \underbrace{P(H|E):P(\Not H|E)}_\text{Posterior odds} \end{aligned}$$` Or even like this: `$$\begin{aligned} \underbrace{P(H):P(\Not H)}_\text{Prior odds} \times \underbrace{P(E|H):P(E|\Not H)}_\text{Strength of evidence} = \underbrace{P(H|E):P(\Not H|E)}_\text{Posterior odds} \end{aligned}$$` Since odds are ratios, mathematically, they work just like fractions. --- # Back to example 1 Urn `\(A\)` contains 8 red balls, 2 green. Urn `\(B\)` contains 6 green balls, 4 red. Fernando draws a ball from an urn (choosing it by tossing a fair coin). He says he has drawn a red ball. You say: "The ball was drawn from urn `\(A\)`." What's the probability that you are right? .center[ <img src="assets/urns.jpeg" alt="" height="300"/> ] We need to determine `\(P(\text{Urn A}|\text{Red})\)`, so we will use Bayes. --- .center[ <img src="assets/urns.jpeg" alt="" height="200"/> ] `$$\begin{aligned} \frac{P(H)}{P(\Not H)} \times \frac{P(E|H)}{P(E|\Not H)} = \frac{P(H|E)}{P(\Not H|E)} \end{aligned}$$` `\(H\)`: The ball was drawn from urn A. <br> `\(E\)`: The ball drawn was red. You know that `\(P(H) = 0.5\)` . This means that `\(P(\Not H) = 0.5\)` <br> The odds of `\(H\)` are then `\(0.5:0.5\)` <br> You also know `\(P(E|H) = 8/10 = 0.8\)` <br> You also know `\(P(E|\Not H) = 4/10 = 0.4\)` `$$\begin{aligned} 0.5:0.5 \times \frac{0.8}{0.4} = 0.4:0.2 = 4:2 \end{aligned}$$` --- `$$\begin{aligned} 0.5:0.5 \times \frac{0.8}{0.4} = 0.4:0.2 = 4:2 \end{aligned}$$` You might say that the odds of having drawn from urn A versus having drawn from urn B are 4:2. Converting odds to probability: `$$\begin{aligned} P(H|E) &= \frac{4}{4+2} \\ &= \frac{4}{6} = \frac{2}{3} = 0.666... \end{aligned}$$` --- # Second exercise > Among people with no symptoms, one person has Disease `\(D\)` for every 1000 people who don’t. There is a test for this disease that always gives a positive result when someone has the disease, but also does so 5 percent of the time when someone does not have the disease. A random person (let’s call it Mary) with no symptoms is tested and gets a positive result. What’s the probability that Mary has the disease? 1. What conditional probability do we want to know? 2. Which probabilities (conditional or not) are given to us in the question? Answers: We want to know the probability that Mary has the disease, given that she has got a positive test result. In other words, our hypothesis is `\(H\)`: Mary has the disease, and the evidence is `\(E\)`: Mary tested positive for the disease. Given this, we want to know `\(P(H|E)\)`. - Odds of `\(H = 1:1000\)` - `\(P(E|H) = 1\)` - `\(P(E|\Not H) = 5/100 = 0.05\)` --- Let's put these quantities in Bayes' theorem: `$$\begin{aligned} \frac{P(H)}{P(\Not H)} \times \frac{P(E|H)}{P(E|\Not H)} &= \frac{P(H|E)}{P(\Not H|E)} \\ \frac{1}{1000} \times \frac{1}{0.05} &= \frac{1}{50} = 1:50 \end{aligned}$$` You might say that the odds that Mary has the disease (versus not having it) after getting a postive test result are 1:50. The odds that Mary has the disease after getting a positive test result increased from 1:1000 to 1:50. Converting to probability: `$$\begin{aligned} P(H|E) &= \frac{1}{1+50} \\ &= \frac{1}{51} = 0.0196... = 1.96... \% \end{aligned}$$` The probability that Mary has the disease after getting a positive test result increased from 1/1001 (or 0.09...%) to 1/51 (or 1.96...%). --- # Revisiting quiz 9 exercise > Joan has symptoms of strep throat. Among all people with similar symptoms, the odds of having strep (versus not having strep) are **4:2**. Joan takes a test to get more conclusive information regarding her condition. The test comes back positive **80%** of the time when someone has strep, but it also comes back positive **5%** of the time when someone doesn’t have strep. Joan’s test comes positive. **What are the odds that Joan has strep vs. not having strep**, _after_ getting the positive test result? (3 bonus points: **What’s the probability that Joan has strep**, _after_ getting the positive test result?) -- `$$\begin{aligned} \text{Prior odds} \times \text{strength of evidence} = \text{posterior odds} \end{aligned}$$` - `\(H\)`: Joan has strep throat - `\(E\)`: Positive test result - Prior odds of `\(H\)`: `\(O(H) = 4:2\)` - Probability of `\(H\)`: `\(P(H) = \frac{4}{4+2} = \frac{4}{6} = .666 = 66.66\%\)` - Strength of evidence - `\(P(E|H) = 0.8\)` - `\(P(E|\Not H) = 0.05\)` --- `$$\begin{aligned} \underbrace{\frac{P(H)}{P(\Not H)}}_\text{Prior odds} \times \underbrace{\frac{P(E|H)}{P(E|\Not H)}}_\text{Strength of evidence} = \underbrace{\frac{P(H|E)}{P(\Not H|E)}}_\text{Posterior odds} \end{aligned}$$` `$$\begin{aligned} (4:2) \times \frac{0.8}{0.05} = 3.2 : 0.10 = 32 : 1\end{aligned}$$` Answer 1: The odds that Joan has strep throat after getting a positive test result are `\(32:1\)`. -- Converting to probability: If `\(O(A) = a:b\)`, then `\(P(A) = \frac{a}{a+b}\)` Since `\(O(H|E) = 32 : 1\)`, then `$$P(H|E) = \frac{32}{32+1} = \frac{32}{33} = .9696... = 96.97 \%$$` --- # Bayesianism Bayesians think that our _degrees of confidence_ should obey Bayes' theorem. Consider the results of the previous exercise. - Probability of strep throat _before_ testing: `\(0.8\)` This means that rational agents should have a `\(0.8\)` credence that Joan has strep throat. - Probability of strep throat _after_ testing: `\(0.9696\)` This means that rational agents should have a `\(0.9696\)` credence that Joan has strep throat (after getting a positive test result). --- # Prior The _prior_ is the _initial_ degree of confidence we should have in the hypothesis before any evidence is assessed. `$$\begin{aligned} \underbrace{O(H)}_\text{Prior odds} \times \underbrace{\frac{P(E|H)}{P(E|\Not H)}}_\text{Strength of evidence} = \underbrace{O(H|E)}_\text{Posterior odds} \end{aligned}$$` In our exercises, typically the prior is given: - `\(1:1000 = 0.09...\%\)` (with no symptoms) - `\(4:2 = 66.66\%\)` (with symptoms) If there's no information about the prior, it's reasonable to assign odds of 1:1 (or 50%) to the hypothesis. --- # Strength of evidence The strength of evidence represents how much the evidence matters to the hypothesis. Consider these two cases: > Test 1 comes back positive **80%** of the time when someone has strep, but it also comes back positive **5%** of the time when someone doesn’t have strep. > Test 2 comes back positive **100%** of the time when someone has strep, but it also comes back positive **100%** of the time when someone doesn’t have strep. Which of these tests is better? Strength of evidence of test 1: `\(\frac{0.8}{0.05} = \frac{80}{5} = \frac{16}{1}\)` Strength of evidence of test 2: `\(\frac{1}{1} = 1\)` Test 1 does provide information about the disease. Test 2 doesn't tell us anything about the presence or absence of the disease. --- # Posterior The _posterior_ is the degree of confidence we should have in the hypothesis after accounting for the evidence. In our exercises, we got these results: - From prior `\(1:1000 = 0.09\%\)`, we got posterior `\(1:50 = 1.96\%\)` - From prior `\(4:2 = 66.66\%\)`, we got posterior `\(32:1 = 96.96 \%\)` The point is that learning some evidence relevant to the hypothesis should alter our degrees of confidence in that hypothesis. --- # Another exercise A cab was involved in a hit and run accident at night. Two cab companies, the Green and the Blue, operate in the city. You are given the following data: 1. 85% of the cabs in the city are Green and 15% are Blue. 2. A witness identified the cab as Blue. The court tested the reliability of the witness under the same circumstances that existed on the night of the accident and concluded that the witness correctly identified each one of the two colors 80% of the time and failed 20% of the time. What is the probability that the cab involved in the accident was blue (rather than green)? This problem is solved in the Worksheet 4 (published in Canvas) --- # Base rate fallacy > Among people with no symptoms, one person has Disease `\(D\)` for every 1000 people who don’t. There is a test for this disease that always gives a positive result when someone has the disease, but also does so 5 percent of the time when someone does not have the disease. A random person (let’s call it Mary) with no symptoms is tested and gets a positive result. What’s the probability that Mary has the disease? Do you remember the right answer to this problem? -- In a survey composed by 61 medical professionals, approximately **75% of respondents answered this question incorrectly.** (Manrai, Bhatia, et al., 2014). --- In a survey composed by 61 medical professionals, approximately **75% of respondents answered this question incorrectly.** (Manrai, Bhatia, et al., 2014). .center[ <img src="assets/nihms773736f1.jpg" alt="" height="380"/> ] Of 61 respondents, 14 provided the correct answer of 2%. The most common answer was 95%, provided by 27 of 61 respondents. The median answer was 66%, which is 33 times larger than the true answer. Why do you think this happened? --- There are three important pieces of data: - Presence of the disease in the population: 1 to 1000 - Probability of positive test result when person does have disease: 1 - Probability of positive test result when person doesn't have disease: 0.05 In the context of Bayes' theorem, the first piece of information corresponds with the _prior odds_ (1:1000). This is also called the _base rate_ (the statistical rate of occurrence of the disease). The second and third pieces of information constitute the _strength of evidence_. `$$\frac{1}{0.05} = \frac{100}{5} = \frac{20}{1}$$` In other words, since the test provides relatively strong evidence (20 to 1 in favor of having disease), doctors overestimate the chances that a random patient has the disease, ignoring the base rate. This mistake (ignoring the _base rate_ and focusing only on the evidence provided) is called the _base rate fallacy_. --- class: middle, center # Base rate fallacy Tendency to ignore the base rate of a feature or event and focus exclusively on the strength of the evidence. Base rate: the statistical rate of occurrence of a feature or event in general. --- - Presence of the disease in the population: 1 to 1000 - Probability of positive test result when person does have disease: 1 - Probability of positive test result when person doesn't have disease: 0.05 .center[ <img src="assets/tree-sick.png" alt="" height="200"/> ] If you had to randomly pick one person who tested positive, what's the probability that such a person is sick (from which branch such a person is most likely to come from)? `$$P(\text{sick|positive}) = \frac{1}{51} = 0.0196$$` `$$P(\text{not sick|positive}) = \frac{50}{51} = 0.98$$` Despite that the test is very good, it's still more likely that a random person who tests positive is not sick. This is so because of the very low base rate of the disease. --- # Another example A cab was involved in a hit and run accident at night. Two cab companies, the Green and the Blue, operate in the city. You are given the following data: 1. 85% of the cabs in the city are Green and 15% are Blue. 2. A witness identified the cab as Blue. The court tested the reliability of the witness under the same circumstances that existed on the night of the accident and concluded that the witness correctly identified each one of the two colors 80% of the time and failed 20% of the time. What is the probability that the cab involved in the accident was blue (rather than green)? --- - Distribution of cabs: 85% green, 15% blue - Probability of correct identification: 80% - Probability of incorrect identification: 20% .center[ <img src="assets/tree-cabs.png" alt="" height="200"/> ] If you had to randomly pick one of the cabs identified as blue, which color such a cab is most likely to be? `$$P(\text{blue|identified as blue}) = \frac{12}{12+17} = \frac{12}{29} = 0.414$$` `$$P(\text{green|identified as blue}) = \frac{17}{12+17} = \frac{17}{29} = 0.586$$` Despite that the witness is more right than wrong on average, it's still more likely that a car identified as blue is actually green. This is so because of the low base rate of blue cabs (vs. green cabs).