Conditional Probability Calculator
Conditional probability answers 'given that B has happened, how likely is A?'.
Enter Values
How to use this calculator
- Always enter P(B), the probability of the condition (the event you are given has happened), as a value between 0 and 1.
- If you already know the joint probability, enter P(A and B) and read P(A|B) straight away. Otherwise, for Bayes' theorem, fill in P(A) and P(B|A) and the calculator builds the joint probability for you.
- Read the result as both a decimal (0 to 1) and a percentage; use the step-by-step panel to see exactly how the joint and conditional values were formed.
How it works
Conditional probability answers 'given that B has happened, how likely is A?'. The definition is P(A | B) = P(A and B) ÷ P(B): you restrict the sample space to only the outcomes where B occurs, then find the fraction of those in which A also occurs. It is only defined when P(B) is greater than 0, since you cannot condition on an event that never happens.
When the joint probability is not known directly, Bayes' theorem supplies it from the reverse conditional: P(A | B) = P(B | A) × P(A) ÷ P(B). Here P(A) is the prior (your belief before the evidence), P(B|A) is the likelihood of the evidence if A is true, and P(A|B) is the posterior (your updated belief). This is why a very accurate test can still give a low posterior when the base rate P(A) is small.
Worked example
Rare disease with a 99% accurate test. A disease affects 1% of people, so the prior P(A) = 0.01. A test detects it 99% of the time when present, so P(B|A) = 0.99. Overall, a positive result occurs in 5.94% of people, so P(B) = 0.0594. Bayes' theorem gives the joint probability P(A and B) = P(B|A) × P(A) = 0.99 × 0.01 = 0.0099, then P(A|B) = 0.0099 ÷ 0.0594 = 0.166667 (16.6667%). So even after a positive test, there is only about a 16.7% chance the person actually has the disease — a classic base-rate result.
Common mistakes
- Confusing P(A|B) with P(B|A). They are usually different — the chance of a positive test given disease is not the same as the chance of disease given a positive test. Bayes' theorem is exactly the tool for flipping between them.
- Forgetting the base rate P(A). A test being 99% accurate does not make a positive result 99% likely to be a true positive; when the condition is rare, most positives can still be false positives.
- Entering a joint probability P(A and B) that is larger than P(B). The overlap of A and B can never be bigger than B alone, so P(A and B) ≤ P(B) — the calculator flags this as an error.
Frequently asked questions
What is the formula for conditional probability?
P(A | B) = P(A and B) ÷ P(B), read as 'the probability of A given B'. You divide the joint probability that both A and B occur by the probability of the condition B. It is only defined when P(B) is greater than 0.
How does Bayes' theorem fit in?
Bayes' theorem rewrites the joint probability using the reverse conditional: P(A | B) = P(B | A) × P(A) ÷ P(B). It lets you update a prior belief P(A) into a posterior P(A|B) after seeing evidence B, which is why it is central to diagnostics, spam filters and machine learning.
Why can a 99% accurate test still be wrong most of the time?
Because of the base rate. If only 1% of people have a condition, most positive results come from the far larger healthy group. Plugging P(A)=0.01, P(B|A)=0.99 and P(B)=0.0594 into Bayes' theorem gives P(A|B) ≈ 0.167, so only about 1 in 6 positives is a true positive.
What is the difference between this and the general probability calculator?
The general probability calculator assumes events are independent and multiplies probabilities. This tool handles dependent events, where knowing B changes the probability of A, using the conditional definition and Bayes' theorem.
Related tools
- Probability Calculator
- Binomial Probability Calculator
- Normal Distribution Calculator
- Confidence Interval Calculator
- Margin of Error Calculator
- Median Calculator
Explore more in Maths, Education & Science.
Tip: Enter any known values to calculate the remaining results.
All calculations run in your browser. Your inputs are never saved or transmitted.



