Conditional Probability Calculator

Conditional Probability Calculator

Fill in a two-way table of counts, or enter the probabilities, and get P(A | B) spelled out in words, along with the reverse P(B | A) that's so easily confused with it.

P(A | B) = P(A and B) ÷ P(B)

Enter the number in each combination
Anot A
B
not B

Rows split by B, columns by A. Name the events to have the answer written out in your words.

Fill in all four boxes of the table

What is Conditional Probability?

Conditional probability is the chance of one event once you already know another has happened. P(A | B), read "the probability of A given B", narrows attention to the cases where B happened and asks how often A happens among them.

The everyday version is a sentence starting "Of the…". "Of the smokers, 15% have the condition" is P(condition | smoker). The group after "of the" is B, and it goes on the bottom of the fraction.

The direction matters enormously. P(A | B) and P(B | A) share the same top line but divide by different groups, so they can be wildly different. Swapping them is one of the most common errors in medicine, law and the news.

Conditional Probability Formula

Definition as given in OpenStax Introductory Statistics, chapter 3. See Sources.

1. From probabilities

P(A | B) = P(A and B) ÷ P(B), provided P(B) > 0

2. From a table of counts

P(A | B) = count(A and B) ÷ count(B)

Read along the B row: the cell where both happen, over the row total.

3. The reverse, and independence

P(B | A) = P(A and B) ÷ P(A)
Independent if P(A | B) = P(A | not B) = P(A)

Worked Example: Smoking and a Lung Condition

Given:
A made-up survey of 1,000 people: 30 smokers with the condition, 170 smokers without, 20 non-smokers with, 780 non-smokers without.
Step 1:
Of the smokers, how many have it? (along the row)
P(condition | smoker) = 30 ÷ 200 = 15%
Step 2:
Of those with it, how many smoke? (down the column)
P(smoker | condition) = 30 ÷ 50 = 60%
Step 3:
Compare with non-smokers:
P(condition | non-smoker) = 20 ÷ 800 = 2.5% → 15 ÷ 2.5 = 6 times
Result:
P(condition | smoker) = 15%

Same 30 people on top, different group underneath. A doctor asking "how worried should this smoker be?" wants the 15%. A researcher asking "what do our patients have in common?" is looking at the 60%.

Spotting "Given" in a Word Problem

Most questions never say "given". Find the group the question has already narrowed you down to: that's B.

Phrases that signal a conditional probability, and how to write them
The question saysWrite it as
“What percentage of smokers have the condition?”P(condition | smoker)
“Among people with the condition, how many smoke?”P(smoker | condition)
“If a student passed, what’s the chance they revised?”P(revised | passed)
“A card is red. What’s the chance it’s a heart?”P(heart | red) = 13/26
“What’s the chance a person smokes and has the condition?”Not conditional: P(smoker and condition)

Common Conditional Probability Mistakes

  • Swapping P(A | B) and P(B | A). In court this is the prosecutor's fallacy: "the evidence is unlikely if innocent" gets heard as "innocence is unlikely". They aren't the same claim.
  • Dividing by the grand total. 30 ÷ 1,000 = 3% is the joint probability. The conditional divides by the B group only.
  • Ignoring the base rate. A test can catch 95% of people with a rare disease, yet most positives can still be healthy. Turning one direction into the other needs Bayes' theorem.
  • Reading a link as cause. A big gap between P(A | B) and P(A | not B) shows the two go together, not that B causes A. Age, for instance, could drive both.

Conditional Probability FAQs

How do I read P(A | B) out loud?

“The probability of A given B.” The vertical bar means “given”, and whatever comes after it is what you already know.

When are P(A | B) and P(B | A) equal?

Only when P(A) = P(B). The more different the two events are in how common they are, the further apart the two conditional probabilities.

How do I tell if A and B are independent?

Compare P(A | B) with P(A | not B). If they’re the same, knowing B tells you nothing about A. In the example, 15% against 2.5% shows a strong link.

Is the difference real or just chance?

With survey data, small gaps can be chance. A chi-square test on the same two-way table tells you whether the gap is bigger than chance would explain.

What if P(B) is zero?

Then P(A | B) is undefined: you can’t ask what happens in cases that never occur.

Can I enter percentages in the probability mode?

Yes. 0.2, 20% and 1/5 all work.

What’s the link with Bayes’ theorem?

Bayes’ theorem turns P(B | A) into P(A | B) using the base rates: P(A | B) = P(B | A) × P(A) ÷ P(B).

Why do my names show in the answer?

Naming A and B turns the result into a plain sentence, which makes it much harder to mix up the two directions.

Sources

  • OpenStax, Introductory Statistics 2e, section 3.4: contingency tables.
  • W. C. Thompson and E. L. Schumann, "Interpretation of statistical evidence in criminal trials: the prosecutor's fallacy and the defense attorney's fallacy", Law and Human Behavior 11 (1987) 167–187.

Related Tools