Conditional Probability

Explore P(A | B) with an interactive Venn diagram and a probability tree

Beginner
Presets
Condition onPeople

Venn diagram(circle and overlap areas are proportional to the probabilities)

0.100.300.20neither: 0.40AB0.100.300.20neither: 0.40ABuniverse shrinks to B

Only the 50 people in B count now. Of them, 30 are also in A, so P(A | B) = 0.30 / 0.50 = 0.600.

Probability tree(leaf: joint probability, with the count out of 100)

0.40A0.60A′P(B|A) = 0.750A ∩ B0.30 (30)P(B′|A) = 0.250A ∩ B′0.10 (10)P(B|A′) = 0.333A′ ∩ B0.20 (20)P(B′|A′) = 0.667A′ ∩ B′0.40 (40)

Conditional probabilities

P(A | B) = P(A∩B) / P(B)
0.600
P(B | A) = P(A∩B) / P(A)
0.750
P(A | B′)
0.200
P(A ∪ B) = P(A) + P(B) − P(A∩B)
0.60

Independence check

P(A) × P(B)
0.2000
P(A ∩ B)
0.3000

Not independent: B makes A more likely.

Contingency table

Out of 100BB′Total
A301040
A′ (not A)204060
Total5050100

What conditioning means

The conditional probability P(A | B), read "the probability of A given B", is the chance that A happens once you know that B has happened. Knowing B rules out every outcome outside B, so B becomes the new universe. Within it, the outcomes where A also happens are exactly A ∩ B, so P(A | B) = P(A ∩ B) / P(B).

The order matters. P(A | B) and P(B | A) share a numerator, P(A ∩ B), but divide it by different things. If 30% of people are in both A and B, 50% are in B and 40% are in A, then P(A | B) = 0.30 / 0.50 = 0.6 while P(B | A) = 0.30 / 0.40 = 0.75. Mixing the two up is one of the most common errors in reasoning about chance.

Two events are independent when learning one tells you nothing about the other: P(A | B) = P(A). Independence is not the same as being disjoint. Disjoint events with positive probabilities are strongly dependent, because if one happens the other cannot.

Shrink the universe

Conditioning on B throws away every outcome outside B. P(A | B) is the share of B that is also in A.

Multiplication rule

Multiply along the branches of a tree: P(A ∩ B) = P(A) × P(B | A). Add the leaves you need to get P(B).

Independence

A and B are independent when P(A | B) = P(A), which is the same as P(A ∩ B) = P(A) × P(B).

Counts make it concrete

A table of 100 or 1,000 people turns every probability into a count, and every conditional probability into a fraction of a row or column.

Key formulas

Definition

P(A | B) = P(A ∩ B) / P(B)

A ∩ B
both A and B happen
P(B)
probability of the condition, must be greater than 0

Multiplication rule and total probability

P(A ∩ B) = P(A) P(B | A),   P(B) = P(A) P(B | A) + P(A′) P(B | A′)

A′
the complement of A, “not A”

Valid overlap

max(0, P(A) + P(B) − 1) ≤ P(A ∩ B) ≤ min(P(A), P(B))

Rules at a glance

RuleFormulaNote
Conditional probabilityP(A | B) = P(A ∩ B) / P(B)Needs P(B) > 0
Multiplication ruleP(A ∩ B) = P(A) P(B | A)Multiply along tree branches
Addition ruleP(A ∪ B) = P(A) + P(B) − P(A ∩ B)Subtract the overlap counted twice
ComplementP(A′ | B) = 1 − P(A | B)Conditioning keeps total probability 1
Total probabilityP(B) = P(B | A) P(A) + P(B | A′) P(A′)Add the leaves of the tree that end in B
IndependenceP(A ∩ B) = P(A) P(B)Equivalent to P(A | B) = P(A)

How to use this visualizer

  1. 1
    Set P(A) and P(B) with the sliders. The P(A ∩ B) slider only allows values that can actually happen: the overlap cannot exceed the smaller event, and it must be at least P(A) + P(B) − 1.
  2. 2
    Click circle B (or press Given B). Everything outside B fades out and the read-out below the diagram explains P(A | B) as a fraction of B. Click A to condition on A instead, or outside both circles to undo.
  3. 3
    Follow the same numbers through the probability tree: multiply P(A) by P(B | A) along the branches to reach P(A ∩ B) at the leaf.
  4. 4
    Read the contingency table as counts out of 100 or 1,000 people. The highlighted column or row is the population you are conditioning on.
  5. 5
    Use the independence panel to compare P(A ∩ B) with P(A) × P(B), and try the presets to see disjoint, nested and independent events.

Common mistake: confusing P(A | B) with P(B | A)

Most professional basketball players are tall, so P(tall | plays in the NBA) is close to 1. That does not make P(plays in the NBA | tall) large: there are millions of tall people and only a few hundred NBA players. Swapping the condition and the event is called the confusion of the inverse, and Bayes' theorem is the tool that converts one into the other correctly.

Practice problems

Problem 1: Students and subjects

In a class of 200 students, 120 take math, 80 take physics and 50 take both. A student is picked at random. Find P(physics | math), P(math | physics) and P(neither). Are taking math and taking physics independent?
Show solution

P(M) = 120/200 = 0.6, P(Ph) = 80/200 = 0.4, P(M ∩ Ph) = 50/200 = 0.25

P(Ph | M) = 50 / 120 ≈ 0.417

P(M | Ph) = 50 / 80 = 0.625

P(M ∪ Ph) = 0.6 + 0.4 − 0.25 = 0.75, so P(neither) = 1 − 0.75 = 0.25 (50 students)

P(M) × P(Ph) = 0.6 × 0.4 = 0.24, which is not equal to 0.25, so they are not independent (slightly positively associated).

P(Ph | M) ≈ 0.417, P(M | Ph) = 0.625, P(neither) = 0.25; not independent

Problem 2: Two aces

Two cards are drawn from a standard 52-card deck without replacement. Find the probability that both are aces, the probability that the second card is an ace, and the probability that the first card was an ace given that the second one is.
Show solution

P(both aces) = P(1st ace) × P(2nd ace | 1st ace) = 4/52 × 3/51 = 12/2652 = 1/221 ≈ 0.00452

P(2nd ace) = 4/52 × 3/51 + 48/52 × 4/51 = (12 + 192)/2652 = 204/2652 = 1/13 ≈ 0.0769

P(1st ace | 2nd ace) = (1/221) / (1/13) = 13/221 = 1/17 ≈ 0.0588

The second card on its own is just as likely to be an ace as the first; only knowing the first card changes it.

1/221 ≈ 0.0045; 1/13 ≈ 0.077; 1/17 ≈ 0.059

Related topics

Discussion

Questions, ideas or a different approach? Join the conversation.