Welcome to the final lesson in our module on the fundamentals of probability. In our previous sessions, we have carefully built a toolkit, exploring the addition rule for "or" scenarios, the concept of conditional probability, and the multiplication rule for "and" scenarios. We saw how these rules function in isolation for both independent and dependent events.
Today, we will put all these pieces together. The goal of this lesson is to equip you to solve complex, applied probability problems by strategically combining the rules you've learned. Real-world challenges rarely announce which formula to use; the essential skill is to deconstruct a problem, translate it into the language of probability, and select the right combination of tools to find a solution. This ability to synthesize is foundational for statistical modeling and machine learning.
Structuring the Unstructured: The Power of Contingency Tables
When faced with a word problem involving multiple events, the first step is to impose structure. In the last lesson, we used probability trees for sequential events. Another, often more versatile tool, is the contingency table (or two-way table). A contingency table organizes data by cross-classifying two categorical variables, allowing us to see joint and marginal counts at a glance. From these counts, calculating any required probability becomes much more intuitive.
Let's begin by seeing how these tables are constructed and used.
Probability Rules with Two Way Tables (or Contingency Tables)
This video from Math and Stats Help provides a clear, step-by-step guide to calculating various probabilities from a two-way table.
Please watch the following segments to get comfortable with the mechanics of contingency tables: Setting up the Table: Watch from the beginning to understand how to calculate row, column, and grand totals. These "marginal totals" are the foundation for all subsequent calculations. "Given" Probabilities: Watch the segment on conditional probability. Notice how the "given" condition restricts our sample space (the denominator) to a specific row or column total. "And" Probabilities: The next segment explains how to find the probability of two events happening together by finding their intersection in the table. "Or" Probabilities: Finally, watch the section on the addition rule. Pay close attention to how the table makes it easy to see the overlap that needs to be subtracted for non-mutually exclusive events.
From Tables to Probabilities: A Comprehensive Example
Now that you have a feel for the mechanics, let's work through a detailed problem that uses a contingency table to explore the interplay between all the probability rules we've covered.
We'll use a real-world dataset to examine the relationship between blood types and medical conditions. You'll see how the table allows us to effortlessly switch between calculating joint, marginal, and conditional probabilities.
This article provides excellent, well-annotated examples using contingency tables. We'll focus on the sections that build and interpret these tables.
Please read the following sections: First, read "Example 1: ABO status and Rh status (independent events)" starting from the subsection "Contingency Tables". Focus on understanding the terminology: cell frequencies, row/column totals (marginal probabilities), and the grand total. Follow the four probability calculations at the end of this section to see how the table is used to find P(A), P(B), P(A \cup B), and P(A \cap B). Next, continue to "Example 2: ABO status and COVID-19 (dependent events)" starting from its introductory paragraph. This example shows how the same calculation methods apply when events are dependent. Pay close attention to how conditional probabilities like P(\text{COVID-19} | \text{Type A}) are calculated by focusing only on the "Type A" row.
The Capstone Problem: Diagnostic Testing and Classifiers
The skills you're developing culminate in one of the most important applications of conditional probability: evaluating the performance of a diagnostic test or a machine learning classifier. When a test (medical or algorithmic) gives a positive result, what is the probability that the condition is truly present? The answer is not as straightforward as it seems.
Your computer science background provides a direct parallel here. The metrics used to evaluate a medical test—sensitivity and specificity—are conceptually identical to the metrics of recall and precision used to evaluate a binary classifier in machine learning.
Let's dive into a problem that makes this connection explicit. We will analyze test results to distinguish between the probability of a test being accurate given a known condition versus the probability of a condition being present given a test result.

First, we will use the OpenIntro Statistics resource which frames this problem in terms of a photo classifier.
Section 3.2: Conditional Probability
This textbook excerpt uses an example of a machine learning photo classifier to introduce conditional probability from a data-centric perspective.
Read sections 3.2.1 and 3.2.3. Start with "Exploring probabilities with a contingency table" to see how the performance of a machine learning classifier is summarized. Then, read "Defining conditional probability". Pay close attention to how it defines P(A|B) and uses the table to calculate probabilities like P(truth is fashion | mach learn is pred fashion). This is the precision of the classifier.
Now, let's tackle the same concept with a classic medical testing scenario. This example will introduce key terminology and formally connect our calculations to Bayes' Theorem, which we will study next.
We return to our main article for its final, most comprehensive example on interpreting COVID-19 test results.
Please read the entire section, "A Final Example". Start with the introduction that sets up the scenario. Pay very close attention to the definitions of True Positive (TP), False Positive (FP), Sensitivity, Specificity, and Positive Predictive Value (PPV). The most important part of this section is understanding the difference between Sensitivity P(\text{Test+}| \text{COVID+}) and PPV P(\text{COVID+}| \text{Test+}). The explanation of the False Positive Paradox is a crucial insight. The section concludes by framing this calculation as an application of Bayes' Theorem, which perfectly sets the stage for our next lesson.
This distinction between sensitivity (recall) and PPV (precision) is critical. A test can be highly sensitive (it correctly identifies most true cases), but if the condition is rare, a positive result may still be more likely to be a false positive than a true positive. This is why understanding the base rate, or prior probability, is so important—a core idea in Bayesian thinking.
Conclusion
In this lesson, we integrated our knowledge of probability to solve complex, applied problems. You learned how to translate verbal descriptions into a structured format like a contingency table, and then use that table to fluidly calculate marginal, joint, union, and conditional probabilities.
Key Takeaways:
- Structure is key: Contingency tables and probability trees are essential tools for organizing the information in a probability problem.
- Translate and solve: The primary skill is translating the problem's question into the correct probability notation (e.g., "A and B", "A or B", "A given B") and then applying the appropriate rule.
- Context matters for conditional probability: The core of many applied problems lies in understanding conditional probability. Be vigilant about the distinction between and . As we saw in the diagnostic test example, they can have vastly different values and interpretations.
- From Tables to Bayes: A contingency table gives us a direct way to calculate posterior probabilities like PPV. This process of updating our belief (the probability of having a disease) in light of new evidence (a positive test) is the essence of Bayesian reasoning.
This lesson serves as a perfect bridge to our next topic: Bayes' Theorem. We've just seen a practical application of it; in the next lesson, we will formalize the theorem and explore its profound implications for updating beliefs and making inferences from data.