Conditional Probability Calculator
This calculator works out conditional probability - the chance that event A is true given that you have observed evidence B - using Bayes' theorem. It suits situations like interpreting a medical test result, a spam filter flag, or a quality control failure, where one piece of evidence needs weighing against how common the underlying event actually is. You enter three percentages: the prior probability P(A), how likely A is before you see any evidence, such as how common a disease is in the population tested; the true positive rate P(B|A), how often the evidence appears when A is true; and the false positive rate P(B|not A), how often the evidence appears even when A is false. From these three inputs the calculator instantly returns P(A|B), the updated probability of A now that B has occurred, alongside P(A|not B), the total probability of the evidence P(B), and P(not A|B). A calculation breakdown shows every intermediate step, including the joint probabilities P(A and B) and P(not A and B), plus a worked example using the default figures so you can check the maths. A plain-English verdict below the results explains whether the evidence has raised or lowered the probability of A, and by how much. Results are mathematically exact for the probabilities you supply, so make sure your estimates are realistic before relying on the output.
1. Prior and Evidence Rates
2. What the Inputs Mean
Use a medical test as an example:
- P(A): how common is the condition in the population being tested?
- P(B|A): if a person has the condition, how often does the test correctly come back positive?
- P(B|not A): if a person does not have the condition, how often does the test incorrectly come back positive?
The calculator works for any A and B, not just medical tests.
Calculation Breakdown
Worked Example Check
With the default inputs (P(A)=30%, P(B|A)=70%, P(B|not A)=20%):
Even though A has only a 30% prior probability, the positive evidence of B raises it to 60%. This is the core insight of Bayesian reasoning.
What Is Conditional Probability?
Conditional probability is the probability that event A will occur, given that event B has already occurred. It is written P(A|B), which is read as "the probability of A given B". The vertical bar means "given that".
The basic formula is:
If you know P(A), P(B|A) and P(B|not A), you can use Bayes' theorem to compute P(A|B) without knowing P(A and B) directly.
Bayes' Theorem
Bayes' theorem expands the conditional probability formula so you can compute P(A|B) from three quantities you typically do know:
The numerator is P(A and B). The denominator is the total probability of B, using the law of total probability: P(B) = P(B|A) x P(A) + P(B|not A) x P(not A).
Step-by-Step Method
- Identify the prior probability P(A): how likely is A before observing B?
- Identify the true positive rate P(B|A): if A is true, how often is B observed?
- Identify the false positive rate P(B|not A): if A is false, how often is B still observed?
- Calculate P(A and B) = P(B|A) x P(A).
- Calculate P(not A and B) = P(B|not A) x P(not A), where P(not A) = 1 - P(A).
- Calculate total P(B) = P(A and B) + P(not A and B).
- Divide: P(A|B) = P(A and B) / P(B).
Worked Example (Default Values)
| Step | Calculation | Value |
|---|---|---|
| Prior P(A) | Given | 0.30 |
| Prior P(not A) | 1 - 0.30 | 0.70 |
| True positive P(B|A) | Given | 0.70 |
| False positive P(B|not A) | Given | 0.20 |
| P(A and B) | 0.70 x 0.30 | 0.2100 |
| P(not A and B) | 0.20 x 0.70 | 0.1400 |
| P(B) | 0.2100 + 0.1400 | 0.3500 |
| P(A|B) | 0.2100 / 0.3500 | 0.6000 (60.00%) |
Why This Matters: The Base Rate Effect
Conditional probability is counterintuitive when the base rate (prior probability) is very different from 50%. Consider a rare disease with a prevalence of 1% in the tested population. A test with a 99% true positive rate and a 5% false positive rate gives:
- P(A and B) = 0.99 x 0.01 = 0.0099
- P(not A and B) = 0.05 x 0.99 = 0.0495
- P(B) = 0.0099 + 0.0495 = 0.0594
- P(disease | positive test) = 0.0099 / 0.0594 = 16.7%
Even with a highly accurate test, a positive result in a low-prevalence population still has an 83% chance of being a false alarm. This is why screening programmes are targeted at higher-risk groups, where the prior probability is higher.
Common Applications
- Medical testing: interpreting a positive or negative diagnostic result given test accuracy and disease prevalence.
- Spam filters: estimating the probability that an email is spam given that it contains certain words.
- Quality control: determining the probability that a defect is from a specific production line given an observed failure.
- Risk assessment: updating the probability of a financial, engineering, or safety event as new data arrives.
- Machine learning: naive Bayes classifiers use this formula to categorise data.
P(A|not B): Probability Given No Evidence
This calculator also shows P(A|not B), the probability of A given that B did not occur. This uses the same Bayes structure with P(not B|A) = 1 - P(B|A) and P(not B|not A) = 1 - P(B|not A). A negative result updates the prior downward by a factor that depends on how reliable the test is at ruling out A.
Related Calculators
- Maths and Stats Calculators: full hub for probability, statistics and maths tools.
- Bayes Theorem Calculator: direct P(A|B) entry using raw probabilities.
- Probability Calculator: basic probability, odds and event combinations.
- Coin Flip Probability Calculator: binomial probability for repeated trials.
- Combination (nCr) Calculator: count combinations for probability problems.
Sources and method: Bayes' theorem from T. Bayes (1763), published posthumously in Philosophical Transactions of the Royal Society. Law of total probability: standard probability theory. Formula reference: DeGroot and Schervish, Probability and Statistics, 4th edition.
Results are mathematically exact given the input probabilities you supply. The calculator assumes the inputs are independent and that A and B are well-defined mutually understood events. It does not perform statistical inference from raw data.