Statistics
Conditional probability calculator
Find the probability of A given B. Enter P(A∩B) and P(B), or the four counts of a two-way table, and the calculator gives P(A|B), the reverse P(B|A) and whether the events are independent.
Decimal, fraction or percentage.
Show the working, step by step
Divide the probability of both by the probability of the condition.
P(A|B) = P(A∩B) ÷ P(B) P(A|B) = 0.12 ÷ 0.3 = 0.4
The complement within B:
P(A′|B) = 1 − 0.4 = 0.6
P(A|B) and P(B|A) share a numerator but have different denominators, so they are usually different numbers. Bayes’ theorem converts one into the other.
The formula
P(A|B) = P(A ∩ B) ÷ P(B), P(B) > 0
Rearranged, it gives the multiplication rule P(A ∩ B) = P(B) × P(A|B), which is how the probability of two dependent events happening together is usually worked out.
A worked example from probabilities
The default: 30% of customers buy a phone case (B), and 12% buy both a case and a screen protector (A ∩ B). What fraction of case buyers also buy a screen protector?
P(A|B) = 0.12 ÷ 0.3 = 0.4
So 40% of case buyers take a screen protector too. If you also know P(A), enter it to get the reverse, P(B|A) = P(A ∩ B) ÷ P(A). With P(A) = 0.2, for example, P(B|A) = 0.12 ÷ 0.2 = 0.6.
A worked example from a table
Switch to the table mode for the second default: 100 students, where A = passed the exam and B = attended the revision class.
| Attended (B) | Did not attend | Total | |
|---|---|---|---|
| Passed (A) | 30 | 20 | 50 |
| Failed | 10 | 40 | 50 |
| Total | 40 | 60 | 100 |
- P(pass | attended) = 30 ÷ 40 = 0.75.
- P(pass | did not attend) = 20 ÷ 60 = 0.333.
- P(attended | pass) = 30 ÷ 50 = 0.6.
- Overall P(pass) = 50 ÷ 100 = 0.5. Because 0.75 ≠ 0.5, passing and attending are not independent.
The table does not show that the class caused the higher pass rate. Students who chose to attend may have been the more motivated ones anyway.
Common mistakes
- Dividing by the grand total. 30 ÷ 100 = 0.3 is P(A ∩ B), not P(A|B).
- Swapping the condition. P(A|B) uses the B total as denominator; P(B|A) uses the A total.
- Assuming independence. P(A ∩ B) = P(A)P(B) only when the events are independent; check it rather than assume it.
Common questions
What is conditional probability?
The probability of A once you know that B has happened, written P(A|B) and read “A given B”. Knowing B shrinks the set of possible outcomes to those inside B, so the probability is the share of B that is also A: P(A|B) = P(A ∩ B) ÷ P(B).
Is P(A|B) the same as P(B|A)?
Almost never. They share the numerator P(A ∩ B) but divide by different things. In the default table P(pass | attended) = 30/40 = 0.75 but P(attended | pass) = 30/50 = 0.6. Confusing the two is known as the prosecutor's fallacy. Bayes' theorem converts one into the other: P(B|A) = P(A|B) P(B) ÷ P(A).
How do I tell whether two events are independent?
Check whether P(A|B) = P(A). If knowing B leaves the probability of A unchanged, the events are independent, and then P(A ∩ B) = P(A) × P(B) as well. In the default table, P(pass) = 0.5 but P(pass | attended) = 0.75, so attending and passing are not independent.
How do I read conditional probabilities from a two-way table?
Condition on a column (or row) by using only that column. P(A|B) is the A-and-B count divided by the B column total; P(B|A) is the same count divided by the A row total. You do not need the grand total at all, which is why conditional probabilities from a table are often easier than they look.
What if P(B) is zero?
Then P(A|B) is undefined: there is no outcome in B to take a share of. The calculator reports this rather than dividing by zero.
Related calculators
-
Bayes' theorem
Turn P(evidence | cause) into P(cause | evidence).
-
Probability calculator
And, or, not and at-least-one probabilities for two events.
-
Chi-square calculator
Test whether the rows and columns of a table are independent.