Most interesting questions involve two variables at once: does studying more go with passing, does a device type go with buying, does a symptom go with a disease? The natural way to record two categorical variables is a two-way table, and three kinds of probability can be read from it. Joint probabilities describe both variables together, marginal probabilities describe one variable while ignoring the other, and conditional probabilities describe one variable given a fixed value of the other. Keeping the three apart is the key to avoiding some of the most common errors in reasoning about data.
- How to read joint, marginal, and conditional probabilities from one table
- Why P(A given B) and P(B given A) are usually different numbers
- How to test independence directly from the table
- How the table connects to Bayes' theorem and the chi-square test
Worked Example
Problem: A tutor records 200 students by how much they studied (Low, Medium, High) and whether they passed an exam:
| Low | Medium | High | Total | |
|---|---|---|---|---|
| Pass | 20 | 50 | 50 | 120 |
| Fail | 40 | 30 | 10 | 80 |
| Total | 60 | 80 | 60 | 200 |
Joint probability
A joint probability is a single cell divided by the grand total. The probability that a randomly chosen student both studied a High amount and passed is P(High and Pass) = 50 ÷ 200 = 0.25. Across all six cells, the joint probabilities add to 1, since every student lands in exactly one cell.
Marginal probability
A marginal probability comes from a row or column total (the "margins" of the table) divided by the grand total. It ignores the other variable completely: P(Pass) = 120 ÷ 200 = 0.60, and P(Low) = 60 ÷ 200 = 0.30. Equivalently, a marginal is the sum of joint probabilities across the other variable: P(Pass) = 0.10 + 0.25 + 0.25 = 0.60.
Conditional probability
A conditional probability restricts attention to one row or column, so the denominator becomes that group's total rather than the grand total. The probability of passing given a Low amount of study is P(Pass | Low) = 20 ÷ 60 ≈ 0.333. In general:
Checking with the example, P(Pass | Low) = 0.10 ÷ 0.30 = 0.333, the same answer. Doing this for each study level gives the pass rate by group:
| Low | Medium | High | |
|---|---|---|---|
| P(Pass | study level) | 0.333 | 0.625 | 0.833 |
The pass rate climbs steadily with study time, from one in three to five in six.
The Direction Matters
The reverse conditional asks a different question. Among students who passed, what fraction studied a Low amount? P(Low | Pass) = 20 ÷ 120 ≈ 0.167, quite different from P(Pass | Low) = 0.333. The two are linked by Bayes' theorem:
Confusing the two directions is a classic mistake. "Most people who passed studied at least a medium amount" (true: 100 of 120, or 83%) is not the same claim as "most people who studied a medium amount passed." Sorting out which group forms the denominator is the whole skill, and it is the same base-rate issue behind the medical testing example in the Bayes article.
Testing Independence From the Table
Two variables are independent if knowing one tells you nothing about the other, which means the conditional probability equals the marginal: P(Pass | Low) = P(Pass). Here P(Pass) = 0.60 but P(Pass | Low) = 0.333, and P(Pass | High) = 0.833, so study level clearly matters. An equivalent check uses the multiplication rule from basic probability: independence requires P(Low and Pass) = P(Low) × P(Pass). The table gives 0.10 for the left side and 0.30 × 0.60 = 0.18 for the right, so the variables are not independent.
This idea is worth pausing on: if the variables were independent, each cell would equal its row total times its column total divided by the grand total. The Low-and-Pass cell would hold 60 × 120 ÷ 200 = 36 students, not 20. Comparing these expected counts with the observed ones is exactly what the chi-square test of independence does. Here the expected counts are 36, 48, 36 in the Pass row and 24, 32, 24 in the Fail row, giving a chi-square statistic of about 31.6 on 2 degrees of freedom and a p-value far below 0.001. The dependence is not a fluke of this sample.
Numeric Variables: Conditional Distributions and Averages
When the variables are numeric, the same three ideas apply, and a conditional distribution has a mean. Suppose X records whether a shopper used a coupon (0 = no, 1 = yes) and Y is the number of items bought (0, 1, or 2), with joint probabilities:
| Y = 0 | Y = 1 | Y = 2 | Marginal of X | |
|---|---|---|---|---|
| X = 0 | 0.30 | 0.20 | 0.10 | 0.60 |
| X = 1 | 0.10 | 0.15 | 0.15 | 0.40 |
| Marginal of Y | 0.40 | 0.35 | 0.25 | 1.00 |
The marginal average is E[Y] = 0(0.40) + 1(0.35) + 2(0.25) = 0.85 items. Now condition on the coupon. Given X = 1, divide each entry in that row by 0.40 to get the conditional distribution 0.25, 0.375, 0.375, whose mean is E[Y | X = 1] = 0.375 + 2(0.375) = 1.125 items. Given X = 0, the conditional distribution is 0.50, 0.333, 0.167, with mean E[Y | X = 0] = 0.40 ÷ 0.60 ≈ 0.667 items. The conditional averages differ, so coupon use and basket size are related. They also tie back to the marginal: 0.60(0.667) + 0.40(1.125) = 0.85, the overall mean. That is, the overall average is the weighted average of the conditional averages. The fitted line in simple linear regression estimates exactly this kind of conditional average, the mean of y given x, and ordinary expected values from expected value are the marginal version of the same idea.
Real-World Uses
Medical screening: a two-way table of test result against true condition supplies every quantity in the sensitivity and specificity framework: sensitivity is a conditional probability within one column, while predictive value is a conditional probability within one row.
Marketing analytics: tables of customer segment against purchase outcome give conversion rates by segment as conditional probabilities, while the marginal shows the overall rate that a single headline figure would hide.
Legal and social debates: statements like "most offenders had property X" and "most people with property X offend" are different conditional probabilities, and mixing them up leads to badly wrong conclusions.
Common Mistakes
Using the wrong denominator. A joint probability divides by the grand total, a conditional divides by a row or column total. Using the grand total for a conditional understates it badly.
Treating P(A | B) as P(B | A). The two are usually unequal, and only equal when P(A) = P(B). Bayes' theorem is the correct bridge between them.
Reading association as causation. The table shows students who study more pass more, but it cannot show that studying caused it. Motivation or prior ability could drive both, as discussed in correlation vs. causation.
Ignoring a hidden third variable. A relationship in the combined table can reverse when the data are split by a third variable, the pattern described in Simpson's paradox.
What is the difference between joint and conditional probability?
Why are they called marginal probabilities?
Can two events be independent and mutually exclusive?
How strong is the relationship in the example table?
Share this article
Written by
Statistics Fundamentals Editorial Team
Written and reviewed by our team of statistics educators. Content is aligned with GCSE, A-Level, AP Statistics, and undergraduate curricula.
About Statistics Fundamentals →