Skip to main content

Introductory Statistics

Section 3.2 Conditional probability

There can be rich relationships between two or more variables that are useful to understand. For example a car insurance company will consider information about a person’s driving history to assess the risk that they will be responsible for an accident. These types of relationships are the realm of conditional probabilities.

Subsection 3.2.1 Exploring probabilities with a contingency table

The photo_classify data set represents a classifier for a sample of 1822 photos from a photo sharing website. Data scientists have been working to improve a classifier for whether the photo is about fashion or not, and these 1822 photos represent a test for their classifier. Each photo gets two classifications: the first is called mach_learn and gives a classification from a machine learning (ML) system of either β€œpred_fashion” or β€œpred_not”. Each of these 1822 photos have also been classified carefully by a team of people, which we take to be the source of truth; this variable is called truth and takes values β€œfashion” and β€œnot”. FigureΒ 3.2.1 summarizes the results.
truth
fashion not Total
mach_learn: pred_fashion 197 22 219
mach_learn: pred_not 112 1491 1603
Total 309 1513 1822
Figure 3.2.1. Contingency table summarizing the photo_classify data set.
Figure 3.2.2. A Venn diagram using boxes for the photo_classify data set.

Example 3.2.3.

If a photo is actually about fashion, what is the chance the ML classifier correctly identified the photo as being about fashion?
Solution.
We can estimate this probability using the data. Of the 309 fashion photos, the ML algorithm correctly classified 197 of the photos:
\begin{equation*} P(\text{mach_learn is pred_fashion} \mid \text{truth is fashion}) = \frac{197}{309} = 0.638 \end{equation*}

Example 3.2.4.

We sample a photo from the data set and learn the ML algorithm predicted this photo was not about fashion. What is the probability that it was incorrect and the photo is about fashion?
Solution.
If the ML classifier suggests a photo is not about fashion, then it comes from the second row in the data set. Of these 1603 photos, 112 were actually about fashion:
\begin{equation*} P(\text{truth is fashion} \mid \text{mach_learn is pred_not}) = \frac{112}{1603} = 0.070 \end{equation*}

Subsection 3.2.2 Marginal and joint probabilities

FigureΒ 3.2.1 includes row and column totals for each variable separately in the photo_classify data set. These totals represent marginal probabilities for the sample, which are the probabilities based on a single variable without regard to any other variables. For instance, a probability based solely on the mach_learn variable is a marginal probability:
\begin{equation*} P(\text{mach_learn is pred_fashion}) = \frac{219}{1822} = 0.12 \end{equation*}
A probability of outcomes for two or more variables or processes is called a joint probability:
\begin{equation*} P(\text{mach_learn is pred_fashion and truth is fashion}) = \frac{197}{1822} = 0.11 \end{equation*}
It is common to substitute a comma for β€œand” in a joint probability, although using either the word β€œand” or a comma is acceptable.

Marginal and joint probabilities.

If a probability is based on a single variable, it is a marginal probability. The probability of outcomes for two or more variables or processes is called a joint probability.
We use table proportions to summarize joint probabilities for the photo_classify sample. These proportions are computed by dividing each count by the table’s total, 1822, to obtain the probabilities in FigureΒ 3.2.5. The joint probability distribution of the mach_learn and truth variables is shown in FigureΒ 3.2.6.
truth: fashion truth: not Total
mach_learn: pred_fashion 0.1081 0.0121 0.1202
mach_learn: pred_not 0.0615 0.8183 0.8798
Total 0.1696 0.8304 1.00
Figure 3.2.5. Probability table summarizing the photo_classify data set.
Joint outcome Probability
mach_learn is pred_fashion and truth is fashion 0.1081
mach_learn is pred_fashion and truth is not 0.0121
mach_learn is pred_not and truth is fashion 0.0615
mach_learn is pred_not and truth is not 0.8183
Total 1.0000
Figure 3.2.6. Joint probability distribution for the photo_classify data set.

Checkpoint 3.2.7.

Verify FigureΒ 3.2.6 represents a probability distribution: events are disjoint, all probabilities are non-negative, and the probabilities sum to 1.
Solution.
Each of the four outcome combinations are disjoint, all probabilities are indeed non-negative, and the sum of the probabilities is \(0.1081 + 0.0121 + 0.0615 + 0.8183 = 1.00\text{.}\)
We can compute marginal probabilities using joint probabilities in simple cases. For example, the probability a randomly selected photo from the data set is about fashion is found by summing the outcomes where truth takes value β€œfashion”:
\begin{align*} P(\text{truth is fashion}) \amp= P(\text{mach_learn is pred_fashion and truth is fashion})\\ \amp\quad + P(\text{mach_learn is pred_not and truth is fashion})\\ \amp= 0.1081 + 0.0615 = 0.1696 \end{align*}

Subsection 3.2.3 Defining conditional probability

The ML classifier predicts whether a photo is about fashion, even if it is not perfect. We would like to better understand how to use information from a variable like mach_learn to improve our probability estimation of a second variable, which in this example is truth.
The probability that a random photo from the data set is about fashion is about 0.17. If we knew the machine learning classifier predicted the photo was about fashion, could we get a better estimate of the probability the photo is actually about fashion? Absolutely. To do so, we limit our view to only those 219 cases where the ML classifier predicted that the photo was about fashion and look at the fraction where the photo was actually about fashion:
\begin{equation*} P(\text{truth is fashion} \mid \text{mach_learn is pred_fashion}) = \frac{197}{219} = 0.900 \end{equation*}
We call this a conditional probability because we computed the probability under a condition: the ML classifier prediction said the photo was about fashion.
There are two parts to a conditional probability, the outcome of interest and the condition. It is useful to think of the condition as information we know to be true, and this information usually can be described as a known outcome or event. We generally separate the text inside our probability notation into the outcome of interest and the condition with a vertical bar:
\begin{equation*} P(\text{truth is fashion} \mid \text{mach_learn is pred_fashion}) = \frac{197}{219} = 0.900 \end{equation*}
The vertical bar β€œ\(|\)” is read as given.
In this equation, we computed the probability a photo was about fashion based on the condition that the ML algorithm predicted it was about fashion as a fraction:
\begin{equation*} \frac{\text{number of cases where truth is fashion and mach_learn is pred_fashion}}{\text{number of cases where mach_learn is pred_fashion}} = \frac{197}{219} = 0.900 \end{equation*}
We considered only those cases that met the condition (mach_learn is β€œpred_fashion”) and then we computed the ratio of those cases that satisfied our outcome of interest (photo was actually about fashion).
Frequently, marginal and joint probabilities are provided instead of count data. For example, disease rates are commonly listed in percentages rather than in a count format. We would like to be able to compute conditional probabilities even when no counts are available, and we use the previous equation as a template to understand this technique.
If we were provided only the information in FigureΒ 3.2.5, i.e. only probability data, then if we took a sample of 1000 photos, we would anticipate about 12.0% or \(0.120 \times 1000 = 120\) would be predicted to be about fashion. Similarly, we would expect about 10.8% or \(0.108 \times 1000 = 108\) to meet both the information criteria and represent our outcome of interest. Then the conditional probability can be computed as:
\begin{equation*} \frac{108}{120} = \frac{0.108}{0.120} = 0.90 \end{equation*}
Here we are examining exactly the fraction of two probabilities, 0.108 and 0.120, which we can write as:
\begin{equation*} P(\text{truth is fashion and mach_learn is pred_fashion}) \quad\text{and}\quad P(\text{mach_learn is pred_fashion}) \end{equation*}
The fraction of these probabilities is an example of the general formula for conditional probability.

Conditional probability.

The conditional probability of outcome \(A\) given condition \(B\) is computed as:
\begin{equation*} P(A \mid B) = \frac{P(A \text{ and } B)}{P(B)} \end{equation*}

Checkpoint 3.2.8.

(a) Write out the following statement in conditional probability notation: β€œThe probability that the ML prediction was correct, if the photo was about fashion”. Here the condition is now based on the photo’s truth status, not the ML algorithm. (b) Determine the probability from part (a). FigureΒ 3.2.5 may be helpful.
Solution.
(a)
\begin{equation*} P(\text{mach_learn is pred_fashion} \mid \text{truth is fashion}) \end{equation*}
(b) The equation for conditional probability indicates we should first find \(P(\text{mach_learn is pred_fashion and truth is fashion}) = 0.1081\) and \(P(\text{truth is fashion}) = 0.1696\text{.}\) Then the ratio represents the conditional probability: \(0.1081 / 0.1696 = 0.6374\text{.}\)

Checkpoint 3.2.9.

(a) Determine the probability that the algorithm is incorrect if it is known the photo is about fashion. (b) Using part (a) and the previous exercise, compute the sum of the two conditional probabilities. (c) Provide an intuitive argument to explain why this sum is 1.
Solution.
(a)
\begin{equation*} P(\text{mach_learn is pred_not} \mid \text{truth is fashion}) = \frac{0.0615}{0.1696} = 0.3626 \end{equation*}
(b) The total equals 1. (c) Under the condition the photo is about fashion, the ML algorithm must have either predicted it was about fashion or predicted it was not about fashion. The complement still works for conditional probabilities, provided the probabilities are conditioned on the same information.

Subsection 3.2.4 Smallpox in Boston, 1721

The smallpox data set provides a sample of 6,224 individuals from the year 1721 who were exposed to smallpox in Boston. Doctors at the time believed that inoculation, which involves exposing a person to the disease in a controlled form, could reduce the likelihood of death.
Each case represents one person with two variables: inoculated and result. The variable inoculated takes two levels: β€œyes” or β€œno”, indicating whether the person was inoculated or not. The variable result has outcomes β€œlived” or β€œdied”. These data are summarized in FigureΒ 3.2.10 and FigureΒ 3.2.11.
inoculated
yes no Total
lived 238 5136 5374
died 6 844 850
Total 244 5980 6224
Figure 3.2.10. Contingency table for the smallpox data set.
inoculated
yes no Total
lived 0.0382 0.8252 0.8634
died 0.0010 0.1356 0.1366
Total 0.0392 0.9608 1.0000
Figure 3.2.11. Table proportions for the smallpox data, computed by dividing each count by the table total, 6224.

Checkpoint 3.2.12.

Write out, in formal notation, the probability a randomly selected person who was not inoculated died from smallpox, and find this probability.
Solution.
\begin{equation*} P(\text{result} = \text{died} \mid \text{inoculated} = \text{no}) = \frac{P(\text{result} = \text{died and inoculated} = \text{no})}{P(\text{inoculated} = \text{no})} = \frac{0.1356}{0.9608} = 0.1411 \end{equation*}

Checkpoint 3.2.13.

Determine the probability that an inoculated person died from smallpox. How does this result compare with the previous exercise?
Solution.
\begin{equation*} P(\text{result} = \text{died} \mid \text{inoculated} = \text{yes}) = \frac{0.0010}{0.0392} = 0.0255 \end{equation*}
(If we avoided rounding errors, we’d get \(6 / 244 = 0.0246\)). The death rate for individuals who were inoculated is only about 1 in 40 while the death rate is about 1 in 7 for those who were not inoculated.

Checkpoint 3.2.14.

The people of Boston self-selected whether or not to be inoculated. (a) Is this study observational or was this an experiment? (b) Can we infer any causal connection using these data? (c) What are some potential confounding variables that might influence whether someone lived or died and also affect whether that person was inoculated?
Solution.
Brief answers: (a) Observational. (b) No, we cannot infer causation from this observational study. (c) Accessibility to the latest and best medical care. There are other valid answers for part (c).

Subsection 3.2.5 General multiplication rule

Section 3.1 on Independence introduced the Multiplication Rule for independent processes. Here we provide the General Multiplication Rule for events that might not be independent.

General Multiplication Rule.

If \(A\) and \(B\) represent two outcomes or events, then
\begin{equation*} P(A \text{ and } B) = P(A \mid B)\times P(B) \end{equation*}
It is useful to think of \(A\) as the outcome of interest and \(B\) as the condition.
This General Multiplication Rule is simply a rearrangement of the conditional probability equation.

Example 3.2.15.

Consider the smallpox data set. Suppose we are given only two pieces of information: 96.08% of residents were not inoculated, and 85.88% of the residents who were not inoculated ended up surviving. How could we compute the probability that a resident was not inoculated and lived?
Solution.
We will compute our answer using the General Multiplication Rule and then verify it using FigureΒ 3.2.11. We want to determine \(P(\text{result} = \text{lived and inoculated} = \text{no})\) and we are given that \(P(\text{result} = \text{lived} \mid \text{inoculated} = \text{no}) = 0.8588\) and \(P(\text{inoculated} = \text{no}) = 0.9608\text{.}\)
Among the 96.08% of people who were not inoculated, 85.88% survived:
\begin{equation*} P(\text{result} = \text{lived and inoculated} = \text{no}) = 0.8588 \times 0.9608 = 0.8251 \end{equation*}
This is equivalent to the General Multiplication Rule. We can confirm this probability in FigureΒ 3.2.11 at the intersection of β€œno” and β€œlived” (with a small rounding error).

Checkpoint 3.2.16.

Use \(P(\text{inoculated} = \text{yes}) = 0.0392\) and \(P(\text{result} = \text{lived} \mid \text{inoculated} = \text{yes}) = 0.9754\) to determine the probability that a person was both inoculated and lived.
Solution.
The answer is 0.0382, which can be verified using FigureΒ 3.2.11.

Checkpoint 3.2.17.

If 97.54% of the inoculated people lived, what proportion of inoculated people must have died?
Solution.
There were only two possible outcomes: lived or died. This means that \(100\% - 97.54\% = 2.46\%\) of the people who were inoculated died.

Sum of conditional probabilities.

Let \(A_1, \ldots, A_k\) represent all the disjoint outcomes for a variable or process. Then if \(B\) is an event, possibly for another variable or process, we have:
\begin{equation*} P(A_1|B) + \cdots + P(A_k|B) = 1 \end{equation*}
The rule for complements also holds when an event and its complement are conditioned on the same information:
\begin{equation*} P(A \mid B) = 1 - P(A^c \mid B) \end{equation*}

Checkpoint 3.2.18.

Based on the probabilities computed above, does it appear that inoculation is effective at reducing the risk of death from smallpox?
Solution.
The samples are large relative to the difference in death rates for the β€œinoculated” and β€œnot inoculated” groups, so it seems there is an association between inoculated and result. However, this is an observational study and we cannot be sure if there is a causal connection. (Further research has shown that inoculation is effective at reducing death rates.)

Subsection 3.2.6 Independence considerations in conditional probability

If two events are independent, then knowing the outcome of one should provide no information about the other. We can show this is mathematically true using conditional probabilities.

Checkpoint 3.2.19.

Let \(X\) and \(Y\) represent the outcomes of rolling two dice.
  1. What is the probability that the first die, \(X\text{,}\) is 1?
  2. What is the probability that both \(X\) and \(Y\) are 1?
  3. Use the formula for conditional probability to compute \(P(Y = 1 \mid X = 1)\text{.}\)
  4. What is \(P(Y=1)\text{?}\) Is this different from the answer from part (c)? Explain.
Solution.
Brief solutions: (a) \(1/6\text{.}\) (b) \(1/36\text{.}\) (c) \(\frac{P(Y = 1 \text{ and } X = 1)}{P(X = 1)} = \frac{1/36}{1/6} = 1/6\text{.}\) (d) The probability is the same as in part (c): \(P(Y=1)=1/6\text{.}\) The probability that \(Y=1\) was unchanged by knowledge about \(X\text{,}\) which makes sense as \(X\) and \(Y\) are independent.
We can show in the above exercise that the conditioning information has no influence by using the Multiplication Rule for independence processes:
\begin{align*} P(Y=1 \mid X=1) \amp= \frac{P(Y=1 \text{ and } X=1)}{P(X=1)}\\ \amp= \frac{P(Y=1) \times P(X=1)}{P(X=1)}\\ \amp= P(Y=1) \end{align*}

Checkpoint 3.2.20.

Ron is watching a roulette table in a casino and notices that the last five outcomes were black. He figures that the chances of getting black six times in a row is very small (about 1/64) and puts his paycheck on red. What is wrong with his reasoning?
Solution.
He has forgotten that the next roulette spin is independent of the previous spins. This fallacy, known as the gambler’s fallacy, is commonly exploited by casinos which post the last several outcomes of betting games.

Subsection 3.2.7 Tree diagrams

Tree diagrams are a tool to organize outcomes and probabilities around the structure of the data. They are most useful when two or more processes occur in a sequence and each process is conditioned on its predecessors.
The smallpox data fit this description. We see the population as split by inoculation: yes and no. Following this split, survival rates were observed for each group. This structure is reflected in the tree diagram shown in FigureΒ 3.2.21.
Figure 3.2.21. A tree diagram of the smallpox data set.
Tree diagrams are annotated with marginal and conditional probabilities. This tree diagram splits the smallpox data by inoculation into the yes and no groups with respective marginal probabilities 0.0392 and 0.9608. The secondary branches are conditioned on the first, so we assign conditional probabilities to these branches. We may construct joint probabilities at the end of each branch in our tree by multiplying the numbers we come across as we move from left to right. These joint probabilities are computed using the General Multiplication Rule:
\begin{align*} P(\text{inoculated} = \text{yes and result} = \text{lived})\\ \amp= P(\text{inoculated} = \text{yes}) \times P(\text{result} = \text{lived} \mid \text{inoculated} = \text{yes})\\ \amp= 0.0392 \times 0.9754 = 0.0382 \end{align*}

Example 3.2.22.

Consider the midterm and final for a statistics class. Suppose 13% of students earned an A on the midterm. Of those students who earned an A on the midterm, 47% received an A on the final, and 11% of the students who earned lower than an A on the midterm received an A on the final. You randomly pick up a final exam and notice the student received an A. What is the probability that this student earned an A on the midterm?
Solution.
The end-goal is to find \(P(\text{midterm} = A \mid \text{final} = A)\text{.}\) To calculate this conditional probability, we need \(P(\text{midterm} = A \text{ and final} = A)\) and \(P(\text{final} = A)\text{.}\) Since we aren’t sure how to proceed, it is useful to organize the information into a tree diagram (shown below).
Figure 3.2.23.
Variables provided with marginal probabilities are often used to create the tree’s primary branches; in this case, the marginal probabilities are provided for midterm grades. The final grades, which correspond to the conditional probabilities provided, will be shown on the secondary branches.
With the tree diagram constructed, we may compute the required probabilities:
\begin{align*} P(\text{midterm} = A \text{ and final} = A) \amp= 0.0611\\ P(\text{final} = A) \amp= P(\text{midterm} = \text{other and final} = A) + P(\text{midterm} = A \text{ and final} = A)\\ \amp= 0.0957 + 0.0611 = 0.1568 \end{align*}
The marginal probability \(P(\text{final} = A)\) was calculated by adding up all the joint probabilities corresponding to final = A. We may now take the ratio of the two probabilities:
\begin{align*} P(\text{midterm} = A \mid \text{final} = A) \amp= \frac{P(\text{midterm} = A \text{ and final} = A)}{P(\text{final} = A)}\\ \amp= \frac{0.0611}{0.1568} = 0.3897 \end{align*}
The probability the student also earned an A on the midterm is about 0.39.

Checkpoint 3.2.24.

After an introductory statistics course, 78% of students can successfully construct tree diagrams. Of those who can construct tree diagrams, 97% passed, while only 57% of those students who could not construct tree diagrams passed. (a) Organize this information into a tree diagram. (b) What is the probability that a randomly selected student passed? (c) Compute the probability a student is able to construct a tree diagram if it is known that she passed.
Solution.
(a) The tree diagram is provided below. (b) Identify which two joint probabilities represent students who passed, and add them: \(P(\text{passed}) = 0.7566+0.1254= 0.8820\text{.}\) (c) \(P(\text{construct tree diagram} \mid \text{passed}) = \frac{0.7566}{0.8820} = 0.8578\text{.}\)
Figure 3.2.25.

Subsection 3.2.8 Bayes’ Theorem

In many instances, we are given a conditional probability of the form \(P(\text{statement about variable 1} \mid \text{statement about variable 2})\) but we would really like to know the inverted conditional probability: \(P(\text{statement about variable 2} \mid \text{statement about variable 1})\text{.}\) Tree diagrams can be used to find the second conditional probability when given the first. However, sometimes it is not possible to draw the scenario in a tree diagram. In these cases, we can apply a very useful and general formula: Bayes’ Theorem.

Example 3.2.26.

In Canada, about 0.35% of women over 40 will develop breast cancer in any given year. A common screening test for cancer is the mammogram, but this test is not perfect. In about 11% of patients with breast cancer, the test gives a false negative: it indicates a woman does not have breast cancer when she does have breast cancer. Similarly, the test gives a false positive in 7% of patients who do not have breast cancer: it indicates these patients have breast cancer when they actually do not. If we tested a random woman over 40 for breast cancer using a mammogram and the test came back positive β€” that is, the test suggested the patient has cancer β€” what is the probability that the patient actually has breast cancer?
Solution.
Notice that we are given sufficient information to quickly compute the probability of testing positive if a woman has breast cancer (\(1.00 - 0.11 = 0.89\)). However, we seek the inverted probability of cancer given a positive test result.
This inverted probability can be broken into two pieces:
\begin{equation*} P(\text{has cancer} \mid \text{mammogram+}) = \frac{P(\text{has cancer and mammogram+})}{P(\text{mammogram+})} \end{equation*}
We can construct a tree diagram to organize these probabilities:
Figure 3.2.27.
The probability the patient has breast cancer and the mammogram is positive is:
\begin{align*} P(\text{has cancer and mammogram+}) \amp= P(\text{mammogram+} \mid \text{has cancer})P(\text{has cancer})\\ \amp= 0.89 \times 0.0035 = 0.00312 \end{align*}
The probability of a positive test result is the sum of the two corresponding scenarios:
\begin{align*} P(\text{mammogram+}) \amp= P(\text{mammogram+ and has cancer}) + P(\text{mammogram+ and no cancer})\\ \amp= P(\text{has cancer})P(\text{mammogram+} \mid \text{has cancer})\\ \amp\quad + P(\text{no cancer})P(\text{mammogram+} \mid \text{no cancer})\\ \amp= 0.0035 \times 0.89 + 0.9965 \times 0.07 = 0.07288 \end{align*}
Then if the mammogram screening is positive for a patient, the probability the patient has breast cancer is:
\begin{align*} P(\text{has cancer} \mid \text{mammogram+}) \amp= \frac{P(\text{has cancer and mammogram+})}{P(\text{mammogram+})}\\ \amp= \frac{0.00312}{0.07288} \approx 0.0428 \end{align*}
That is, even if a patient has a positive mammogram screening, there is still only about a 4% chance that she has breast cancer.
ExampleΒ 3.2.26 highlights why doctors often run more tests regardless of a first positive test result. When a medical condition is rare, a single positive test isn’t generally definitive.
Consider again the last equation of ExampleΒ 3.2.26. Using the tree diagram, we can see that the numerator is:
\begin{equation*} P(\text{has cancer and mammogram+}) = P(\text{mammogram+} \mid \text{has cancer})P(\text{has cancer}) \end{equation*}
The denominatorβ€”the probability the screening was positiveβ€”is the sum of probabilities for each positive screening scenario:
\begin{align*} P(\text{mammogram+}) \amp= P(\text{mammogram+ and no cancer}) + P(\text{mammogram+ and has cancer})\\ \amp= P(\text{mammogram+} \mid \text{no cancer})P(\text{no cancer})\\ \amp\quad + P(\text{mammogram+} \mid \text{has cancer})P(\text{has cancer}) \end{align*}

Bayes’ Theorem: inverting probabilities.

Consider the following conditional probability for variable 1 and variable 2:
\begin{equation*} P(\text{outcome } A_1 \text{ of variable 1} \mid \text{outcome } B \text{ of variable 2}) \end{equation*}
Bayes’ Theorem states that this conditional probability can be identified as:
\begin{equation*} \frac{P(B \mid A_1) P(A_1)}{P(B \mid A_1) P(A_1) + P(B \mid A_2) P(A_2) + \cdots + P(B \mid A_k) P(A_k)} \end{equation*}
where \(A_2, A_3, \ldots, A_k\) represent all other possible outcomes of the first variable.
Bayes’ Theorem is a generalization of what we have done using tree diagrams. The numerator identifies the probability of getting both \(A_1\) and \(B\text{.}\) The denominator is the marginal probability of getting \(B\text{.}\) This bottom component of the fraction appears long and complicated since we have to add up probabilities from all of the different ways to get \(B\text{.}\) We always completed this step when using tree diagrams. However, we usually did it in a separate step so it didn’t seem as complex.
To apply Bayes’ Theorem correctly, there are two preparatory steps:
  1. First identify the marginal probabilities of each possible outcome of the first variable: \(P(A_1), P(A_2), \ldots, P(A_k)\text{.}\)
  2. Then identify the probability of the outcome \(B\text{,}\) conditioned on each possible scenario for the first variable: \(P(B \mid A_1), P(B \mid A_2), \ldots, P(B \mid A_k)\text{.}\)
Once each of these probabilities are identified, they can be applied directly within the formula. Bayes’ Theorem tends to be a good option when there are so many scenarios that drawing a tree diagram would be complex.

Checkpoint 3.2.28.

Jose visits campus every Thursday evening. However, some days the parking garage is full, often due to college events. There are academic events on 35% of evenings, sporting events on 20% of evenings, and no events on 45% of evenings. When there is an academic event, the garage fills up about 25% of the time, and it fills up 70% of evenings with sporting events. On evenings when there are no events, it only fills up about 5% of the time. If Jose comes to campus and finds the garage full, what is the probability that there is a sporting event? Use a tree diagram to solve this problem.
Solution.
The tree diagram with three primary branches is shown below. Next, we identify two probabilities from the tree diagram: (1) The probability that there is a sporting event and the garage is full: 0.14. (2) The probability the garage is full: \(0.0875 + 0.14 + 0.0225 = 0.25\text{.}\) Then the solution is the ratio of these probabilities: \(\frac{0.14}{0.25} = 0.56\text{.}\) If the garage is full, there is a 56% probability that there is a sporting event.
Figure 3.2.29.

Example 3.2.30.

Here we solve the same problem presented in the previous exercise, except this time we use Bayes’ Theorem.
Solution.
The outcome of interest is whether there is a sporting event (call this \(A_1\)), and the condition is that the lot is full (\(B\)). Let \(A_2\) represent an academic event and \(A_3\) represent there being no event on campus. Then the given probabilities can be written as:
\begin{gather*} P(A_1) = 0.2 \quad P(A_2) = 0.35 \quad P(A_3) = 0.45\\ P(B \mid A_1) = 0.7 \quad P(B \mid A_2) = 0.25 \quad P(B \mid A_3) = 0.05 \end{gather*}
Bayes’ Theorem can be used to compute the probability of a sporting event (\(A_1\)) under the condition that the parking lot is full (\(B\)):
\begin{align*} P(A_1 \mid B) \amp= \frac{P(B \mid A_1) P(A_1)}{P(B \mid A_1) P(A_1) + P(B \mid A_2) P(A_2) + P(B \mid A_3) P(A_3)}\\ \amp= \frac{(0.7)(0.2)}{(0.7)(0.2) + (0.25)(0.35) + (0.05)(0.45)}\\ \amp= 0.56 \end{align*}
Based on the information that the garage is full, there is a 56% probability that a sporting event is being held on campus that evening.

Checkpoint 3.2.31.

Use the information in CheckpointΒ 3.2.28 and ExampleΒ 3.2.30 to verify the probability that there is an academic event conditioned on the parking lot being full is 0.35.
Solution.
Short answer:
\begin{align*} P(A_2 \mid B) \amp= \frac{P(B \mid A_2) P(A_2)}{P(B \mid A_1) P(A_1) + P(B \mid A_2) P(A_2) + P(B \mid A_3) P(A_3)}\\ \amp= \frac{(0.25)(0.35)}{(0.7)(0.2) + (0.25)(0.35) + (0.05)(0.45)}\\ \amp= 0.35 \end{align*}

Checkpoint 3.2.32.

In CheckpointΒ 3.2.28 and ExampleΒ 3.2.30, you found that if the parking lot is full, the probability there is a sporting event is 0.56 and the probability there is an academic event is 0.35. Using this information, compute \(P(\text{no event} \mid \text{the lot is full})\text{.}\)
Solution.
Each probability is conditioned on the same information that the garage is full, so the complement may be used: \(1.00 - 0.56 - 0.35 = 0.09\text{.}\)
The last several exercises offered a way to update our belief about whether there is a sporting event, academic event, or no event going on at the school based on the information that the parking lot was full. This strategy of updating beliefs using Bayes’ Theorem is actually the foundation of an entire section of statistics called Bayesian statistics. While Bayesian statistics is very important and useful, we will not have time to cover much more of it in this book.

Exercises 3.2.9 Exercises

1. Joint and conditional probabilities.

Given that P(A) = 0.3 and P(B) = 0.7:
  1. Can you compute P(A and B) if you only know P(A) and P(B)?
  2. Assuming that events A and B arise from independent random processes,
    1. what is P(A and B)?
    2. what is P(A or B)?
    3. what is P(A|B)?
  3. If we are given that P(A and B) = 0.1, are the random variables giving rise to events A and B independent?
  4. If we are given that P(A and B) = 0.1, what is P(A|B)?

2. PB & J.

Suppose 80% of people like peanut butter, 89% like jelly, and 78% like both. Given that a randomly sampled person likes peanut butter, what’s the probability that he also likes jelly?

3. Global warming.

A Pew Research poll asked 1,306 Americans "From what you’ve read and heard, is there solid evidence that the average temperature on earth has been getting warmer over the past few decades, or not?". The table below shows the distribution of responses by party and ideology, where the counts have been replaced with relative frequencies.
Table 3.2.33. Global warming poll results
Earth is warming Not warming Don’t Know/Refuse Total
Conservative Republican 0.11 0.20 0.02 0.33
Mod/Lib Republican 0.06 0.06 0.01 0.13
Mod/Cons Democrat 0.25 0.07 0.02 0.34
Liberal Democrat 0.18 0.01 0.01 0.20
Total 0.60 0.34 0.06 1.00
  1. Are believing that the earth is warming and being a liberal Democrat mutually exclusive?
  2. What is the probability that a randomly chosen respondent believes the earth is warming or is a liberal Democrat?
  3. What is the probability that a randomly chosen respondent believes the earth is warming given that he is a liberal Democrat?
  4. What is the probability that a randomly chosen respondent believes the earth is warming given that he is a conservative Republican?
  5. Does it appear that whether or not a respondent believes the earth is warming is independent of their party and ideology? Explain your reasoning.
  6. What is the probability that a randomly chosen respondent is a moderate/liberal Republican given that he does not believe that the earth is warming?

4. Health coverage, relative frequencies.

The Behavioral Risk Factor Surveillance System (BRFSS) is an annual telephone survey designed to identify risk factors in the adult population and report emerging health trends. The following table displays the distribution of health status of respondents to this survey (excellent, very good, good, fair, poor) and whether or not they have health insurance.
Table 3.2.34. Health status by insurance coverage
Excellent Very good Good Fair Poor Total
No 0.0230 0.0364 0.0427 0.0192 0.0050 0.1262
Yes 0.2099 0.3123 0.2410 0.0817 0.0289 0.8738
Total 0.2329 0.3486 0.2838 0.1009 0.0338 1.0000
  1. Are being in excellent health and having health coverage mutually exclusive?
  2. What is the probability that a randomly chosen individual has excellent health?
  3. What is the probability that a randomly chosen individual has excellent health given that he has health coverage?
  4. What is the probability that a randomly chosen individual has excellent health given that he doesn’t have health coverage?
  5. Do having excellent health and having health coverage appear to be independent?

5. Burger preferences.

A 2010 SurveyUSA poll asked 500 Los Angeles residents, "What is the best hamburger place in Southern California? Five Guys Burgers? In-N-Out Burger? Fat Burger? Tommy’s Hamburgers? Umami Burger? Or somewhere else?" The distribution of responses by gender is shown below.
Table 3.2.35. Burger preferences by gender
Male Female Total
Five Guys Burgers 5 6 11
In-N-Out Burger 162 181 343
Fat Burger 10 12 22
Tommy’s Hamburgers 27 27 54
Umami Burger 5 1 6
Other 26 20 46
Not Sure 13 5 18
Total 248 252 500
  1. Are being female and liking Five Guys Burgers mutually exclusive?
  2. What is the probability that a randomly chosen male likes In-N-Out the best?
  3. What is the probability that a randomly chosen female likes In-N-Out the best?
  4. What is the probability that a man and a woman who are dating both like In-N-Out the best? Note any assumption you make and evaluate whether you think that assumption is reasonable.
  5. What is the probability that a randomly chosen person likes Umami best or that person is female?

6. Assortative mating.

Assortative mating is a nonrandom mating pattern where individuals with similar genotypes and/or phenotypes mate with one another more frequently than what would be expected under a random mating pattern. Researchers studying this topic collected data on eye colors of 204 Scandinavian men and their female partners. The table below summarizes the results.
Table 3.2.36. Eye color of male and female partners
Blue Brown Green Total
Blue 78 23 13 114
Brown 19 23 12 54
Green 11 9 16 36
Total 108 55 41 204
  1. What is the probability that a randomly chosen male respondent or his partner has blue eyes?
  2. What is the probability that a randomly chosen male respondent with blue eyes has a partner with blue eyes?
  3. What is the probability that a randomly chosen male respondent with brown eyes has a partner with blue eyes? What about the probability of a randomly chosen male respondent with green eyes having a partner with blue eyes?
  4. Does it appear that the eye colors of male respondents and their partners are independent? Explain your reasoning.

7. Drawing box plots.

After an introductory statistics course, 80% of students can successfully construct box plots. Of those who can construct box plots, 86% passed, while only 65% of those students who could not construct box plots passed.
  1. Construct a tree diagram of this scenario.
  2. Calculate the probability that a student is able to construct a box plot if it is known that he passed.

8. Predisposition for thrombosis.

A genetic test is used to determine if people have a predisposition for thrombosis, which is the formation of a blood clot inside a blood vessel that obstructs the flow of blood through the circulatory system. It is believed that 3% of people actually have this predisposition. The genetic test is 99% accurate if a person actually has the predisposition, meaning that the probability of a positive test result when a person actually has the predisposition is 0.99. The test is 98% accurate if a person does not have the predisposition. What is the probability that a randomly selected person who tests positive for the predisposition by the test actually has the predisposition?

9. It’s never lupus.

Lupus is a medical phenomenon where antibodies that are supposed to attack foreign cells to prevent infections instead see plasma proteins as foreign bodies, leading to a high risk of blood clotting. It is believed that 2% of the population suffer from this disease. The test is 98% accurate if a person actually has the disease. The test is 74% accurate if a person does not have the disease. There is a line from the Fox television show House that is often used after a patient tests positive for lupus: "It’s never lupus." Do you think there is truth to this statement? Use appropriate probabilities to support your answer.

10. Exit poll.

Edison Research gathered exit poll results from several sources for the Wisconsin recall election of Scott Walker. They found that 53% of the respondents voted in favor of Scott Walker. Additionally, they estimated that of those who did vote in favor for Scott Walker, 37% had a college degree, while 44% of those who voted against Scott Walker had a college degree. Suppose we randomly sampled a person who participated in the exit poll and found that he had a college degree. What is the probability that he voted in favor of Scott Walker?