Maths
What is conditional probability, and how do you calculate it?
Quick answer
Conditional probability is the chance of an event A when you already know event B has happened. It is written P(A|B) and found with P(A|B) = P(A and B) ÷ P(B).
In one sentence
Conditional probability is the probability that something happens when you already know that something else has happened.
Explained
Roll a fair dice. The probability of a 6 is 1/6. Now a friend peeks and says: "It's even." Suddenly only 2, 4 and 6 are possible, and one of those three is a 6. The probability of a 6 given that the number is even is 1/3. The dice did not change; what you know did, and that shrinks the list of possible outcomes.
bag
ball
rain
We write this as P(A|B) and read it as "the probability of A given B". The vertical bar means "given". A is the event you are interested in; B is what you already know. The formula is:
P(A|B) = P(A and B) ÷ P(B), as long as P(B) is not 0.
In words: out of all the times B happens, what fraction of them does A happen too? With counts instead of probabilities it is even simpler: number of outcomes in both A and B ÷ number of outcomes in B. If you know basic probability and fractions, you already have everything you need.
Rearranging the formula gives the multiplication rule, which is what you use on a tree diagram:
P(A and B) = P(B) × P(A|B)
The probabilities on the second set of branches of a tree diagram are conditional: they assume the first branch has already happened. That is why "without replacement" questions change the numbers on the second branches.
Two events are independent when knowing one tells you nothing about the other. Then P(A|B) = P(A), and the multiplication rule becomes P(A and B) = P(A) × P(B). Coin tosses are independent; drawing two sweets from a bag without putting the first one back is not.
Watch the order: P(A|B) and P(B|A) are usually different. Most footballers can run fast, but most fast runners are not footballers. Turning one into the other is the job of Bayes' theorem: P(B|A) = P(A|B) × P(B) ÷ P(A).
Examples
A two-way table. A class of 30 students was asked about sport and music:
| Plays an instrument | No instrument | Total | |
|---|---|---|---|
| Plays a sport | 8 | 10 | 18 |
| No sport | 4 | 8 | 12 |
| Total | 12 | 18 | 30 |
- Probability that a student plays an instrument, given they play a sport: look only at the sport row. 8 out of 18, so 8/18 = 4/9.
- Probability that a student plays a sport, given they play an instrument: look only at the instrument column. 8 out of 12, so 8/12 = 2/3. Not the same as 4/9: the order matters.
With the formula. P(A and B) = 0.12 and P(B) = 0.4, so P(A|B) = 0.12 ÷ 0.4 = 0.3.
Without replacement. A bag holds 5 red and 3 blue balls. You take one, keep it, and take another. If the first was red, 4 red balls are left out of 7, so P(second red | first red) = 4/7. The chance that both are red is 5/8 × 4/7 = 20/56 = 5/14.
A medical test (made-up numbers). Imagine 1% of people have a condition. A test finds 90% of people who have it, but also gives a positive result for 5% of people who do not. Picture 10,000 people: 100 have the condition and 90 of them test positive; 9,900 do not, and 5% of them, 495 people, also test positive. So 90 + 495 = 585 people test positive, and P(has the condition | positive test) = 90 ÷ 585 = 2/13, about 15%. Because the condition is rare, most positive results are false alarms, which is why a first positive result is usually checked with a second test.
Common mistakes
- Swapping the order. P(A|B) is not P(B|A). Fix: say it in words ("the chance of A among the B's") before you calculate.
- Dividing by the wrong total. With "given B", divide by the number (or probability) of B, not by the whole group. In the class above, it is 8/18, not 8/30.
- Confusing "given" with "and". P(A and B) is a share of everyone; P(A|B) is a share of B only. P(A and B) is never bigger than P(A|B).
- Forgetting to update the second draw. Without replacement, both the number of items left and the number of that colour go down by one.
Step by step
Step by step
- Find the conditionLook for "given", "if", "among those who" or "knowing that". That event is B.
- Find the new totalCount the outcomes in B, or find P(B). This replaces the whole group.
- Find the overlapCount the outcomes that are in both A and B, or find P(A and B).
- DivideP(A|B) = overlap ÷ new total.
- CheckThe answer must be between 0 and 1. Compare it with P(A): if it is the same, A and B are independent.
Practice questions
Conditional probability
Try each one, then check your answer.
- Roll a fair dice. Find P(5 | odd).
Show answer
Odd numbers: 1, 3, 5 (3 outcomes). One of them is 5: 1/3 - Roll a fair dice. Find P(even | greater than 2).
Show answer
Greater than 2: 3, 4, 5, 6. Even among them: 4 and 6. 2/4 = 1/2 - Roll a fair dice. Find P(less than 3 | even).
Show answer
Even: 2, 4, 6. Only 2 is less than 3: 1/3 - P(A and B) = 0.2 and P(B) = 0.5. Find P(A|B).
Show answer
0.2 ÷ 0.5 = 0.4 - P(A and B) = 0.15 and P(A) = 0.6. Find P(B|A).
Show answer
0.15 ÷ 0.6 = 0.25 - P(B) = 0.3 and P(A|B) = 0.5. Find P(A and B).
Show answer
0.3 × 0.5 = 0.15 - A bag has 4 red and 6 green counters. Two are taken without replacement. Find P(second red | first red).
Show answer
3 red are left out of 9: 3/9 = 1/3 - Same bag. Find P(both red).
Show answer
4/10 × 3/9 = 12/90 = 2/15 - Same bag. Find P(second red | first green).
Show answer
4 red are left out of 9: 4/9 - Use the class table above. Find P(sport | no instrument).
Show answer
18 students play no instrument; 10 of them play a sport: 10/18 = 5/9 - Use the class table. Find P(no sport | instrument).
Show answer
12 play an instrument; 4 of them play no sport: 4/12 = 1/3 - P(A) = 0.5, P(B) = 0.4 and P(A and B) = 0.2. Are A and B independent?
Show answer
0.5 × 0.4 = 0.2 = P(A and B), and P(A|B) = 0.2 ÷ 0.4 = 0.5 = P(A): yes - P(A) = 0.3, P(B) = 0.6 and P(A and B) = 0.1. Are A and B independent?
Show answer
0.3 × 0.6 = 0.18, which is not 0.1: no - Two fair coins are tossed. Given that at least one is heads, find P(both heads).
Show answer
At least one head: HH, HT, TH (3 outcomes). Both heads: 1 of them: 1/3 - Two fair dice are rolled. Given that the total is 8, find P(both dice show 4).
Show answer
Total 8: (2,6), (3,5), (4,4), (5,3), (6,2), 5 outcomes. Only (4,4) works: 1/5 - P(A|B) = 0.6, P(B) = 0.5 and P(A) = 0.4. Find P(B|A).
Show answer
P(A and B) = 0.5 × 0.6 = 0.3, so P(B|A) = 0.3 ÷ 0.4 = 0.75
Word problems
Conditional probability in real life
Try each one, then check your answer.
- In a group of 40 students, 25 like football, and 10 of the football fans also like basketball. A football fan is picked at random. What is the probability they like basketball?
Show answer
10 ÷ 25 = 2/5 (0.4) - The probability of rain tomorrow is 0.3. If it rains, the probability the bus is late is 0.4; if it does not rain, it is 0.1. What is the probability that it rains and the bus is late?
Show answer
0.3 × 0.4 = 0.12 - Same situation. What is the probability that the bus is late?
Show answer
Rain and late: 0.12. No rain and late: 0.7 × 0.1 = 0.07. Total: 0.19 - Same situation. The bus was late. What is the probability that it rained?
Show answer
0.12 ÷ 0.19 = 12/19 ≈ 0.63 - A box of 12 eggs has 3 cracked ones. You take two eggs without looking. What is the probability that the second is cracked, given that the first one was?
Show answer
2 cracked are left out of 11: 2/11 - A machine checks 2,000 phones, and 5% of them are faulty. It flags 95% of the faulty phones and wrongly flags 4% of the good ones. A phone is flagged. What is the probability it is really faulty?
Show answer
Faulty: 100, flagged 95. Good: 1,900, flagged 76. 95 ÷ (95 + 76) = 95/171 = 5/9 ≈ 0.56
Questions people ask
What is the conditional probability formula?
P(A|B) = P(A and B) ÷ P(B). It is the probability of both events divided by the probability of the event you already know happened. With counts: outcomes in both ÷ outcomes in B.
How do you read P(A|B)?
Read it as "the probability of A given B". The bar means "given". The event after the bar is the one you already know has happened.
What is conditional probability for independent events?
For independent events, the condition makes no difference: P(A|B) = P(A). A coin landing heads is still a 1/2 chance, whatever the last toss was.
What is the difference between conditional probability and Bayes' theorem?
Conditional probability is the idea and the basic formula. Bayes' theorem is a rule built from it that turns P(A|B) round into P(B|A). The medical test example above is a Bayes calculation.
How do you use a tree diagram for conditional probability?
Write the first event on the first branches and the second event on the next branches, using the probabilities that apply once the first event has happened. Multiply along each path. For a "given" question, divide the path you want by the sum of the paths that match the condition.
Quick quiz
Conditional probability
Check what you know with 5 quick questions.
Question 1 of 5
You roll a fair dice and you are told the number is even. What is the probability that it is a 4?
Practise it
Try it
Practise conditional probability with unlimited questions
Probability and statistics worksheets
Practise it step by step in a full course: Grade 11 Maths
For grown-ups
Related topics
Probability
Probability measures how likely something is to happen, on a scale from 0 (impossible) to 1 (certain). A fair coin landing heads has a probability of 1/2.
Venn diagrams
A Venn diagram uses overlapping circles to sort things into groups. The overlap shows what belongs to both groups, and the outside shows what belongs to neither.
Fractions
A fraction is part of a whole that has been split into equal parts. In ¾, the bottom number says how many equal parts and the top says how many you have.
Percentages
A percentage is a number out of 100, written with the sign %. So 25% means 25 out of every 100, which is the same as one quarter.
Sample space
A sample space is the list of every possible outcome of an experiment. Flipping a coin has the sample space {H, T}; rolling a dice has {1, 2, 3, 4, 5, 6}.
The binomial distribution
The binomial distribution B(n, p) gives the probability of k successes in n independent trials, each with success probability p: P(X = k) = ⁿCₖ pᵏ (1 − p)ⁿ⁻ᵏ. Its mean is np.