Bayes' Theorem
Bayes' theorem describes the inversion of conditional probabilities.
Free · no credit card · in your study plan in 2 minutes
Formula
P(A|B) = \frac{P(B|A) \cdot P(A)}{P(B)}Variables & units – Bayes' Theorem
| Symbol | Meaning | Unit |
|---|---|---|
| P(A|B) | Conditional probability of A given B (posterior) | dimensionless |
| P(B|A) | Conditional probability of B given A (likelihood) | dimensionless |
| P(A) | Prior probability of A | dimensionless |
| P(B) | Marginal probability of B | dimensionless |
Derivation & background – Bayes' Theorem
Thomas Bayes (1701 to 1761) developed the theorem, published posthumously in 1763. It is the foundation of Bayesian statistics and machine learning. Counterintuitive: a positive test with a 1% base rate and 99% sensitivity yields only a 50% probability of disease.
Exam blueprint
Validity range
Applies to events with P(B)>0; probabilities must be defined consistently on the same sample space.
Derivation steps
Bayes follows by equating the joint probability P(A∩B).
- 1P(A∩B)=P(A|B)P(B).
- 2Also P(A∩B)=P(B|A)P(A); solve for P(A|B).
Rearrangements
Compute evidence
The evidence is often the decisive denominator.
Task variant
Why is the base rate important?
P(A) scales the numerator; rare events can remain unlikely despite a good test.
Common mistakes
Treating P(A|B) and P(B|A) as equal.
Bayes shows precisely how to convert between the two directions.
Exam context
- Often used in medical tests, quality control, spam filters and diagnostics.
These mistakes cost points in real exams. The set drills them until they stick.
Formula cluster
Conditional probability
Foundation for statistics, inference and model evaluation.
Worked example
Medical test: a disease occurs at 1% (P(K) = 0.01). The test is 95% sensitive: P(+|K) = 0.95. False-positive rate 5%: P(+|¬K) = 0.05. P(K|+) = (0.95×0.01)/(0.95×0.01 + 0.05×0.99) ≈ 16%.
Applications
Medical diagnostics, spam filters, machine learning, forensics, risk analysis
Quanta exam set
Curated exam set for "Bayes' Theorem":
Question (front)
Which formula describes Bayes' Theorem?
Answer in your set
Question (front)
How do you rearrange P(A|B) = P(B|A)·P(A) / P(B) for Compute evidence?
Answer in your set
Question (front)
Which common mistake happens with Bayes' Theorem?
Answer in your set
+ 7 more cards: units, variables, derivation, example, exam task
These 10 cards are ready. One click and they sit in your deck, FSRS schedules the reviews until exam day.
Scientific sources
Common notations & search queries
Related formulas
More Mathematics formulas
Frequently asked questions about Bayes' Theorem
How do you calculate a conditional probability with Bayes theorem?+
Multiply the reverse conditional probability P(B|A) by the base probability P(A) and divide by the total probability P(B): P(A|B) = P(B|A)·P(A)/P(B). The denominator P(B) is often computed via the law of total probability as P(B|A)·P(A) + P(B|¬A)·P(¬A). Example medical test: disease with 1 percent prevalence, 95 percent sensitivity, 5 percent false-positive rate. Then P(D|+) = (0.95·0.01)/(0.95·0.01 + 0.05·0.99) ≈ 16 percent. Despite a good test, a positive result is surprisingly often a false alarm, because the disease is rare and the many false positives outweigh the few true hits. Make sure to build the denominator fully from both contributions, otherwise the result is wrong.
Why is the base rate so important?+
The base rate P(A) scales the numerator in Bayes theorem and largely determines the result. If an event is very rare, it often remains unlikely even after a positive test result, because the many false-positive cases from the large healthy group outweigh the few true hits. This is exactly what the medical-test example shows: for a disease with only 1 percent prevalence, the probability of actually being ill is only about 16 percent despite 95 percent sensitivity. Anyone who ignores the base rate dramatically overestimates the significance of a test. This fallacy is called the base rate fallacy and is widespread in medicine and forensics.
What is the difference between P(A|B) and P(B|A)?+
P(A|B) and P(B|A) are two different conditional probabilities and must not be treated as equal. P(A|B) is the probability of A given that B has already occurred; P(B|A) is conversely the probability of B given that A has occurred. An example makes the difference clear: the probability of being ill given a positive test differs greatly from the probability of testing positive given that you are ill. This very confusion is a classic fallacy. Bayes theorem shows how to convert correctly between the two directions, namely by including the base rates P(A) and P(B).
How do you update a probability with new information?+
Bayes theorem is the tool to turn an initial probability, the prior probability P(A), into an updated posterior probability P(A|B) in the light of new observations. You multiply the prior by the likelihood P(B|A), that is the probability of the observation under the assumption, and normalize with the total probability P(B). The result takes into account both the prior knowledge and the new evidence. If you obtain further data, you can use the posterior again as a prior and repeat the process. This stepwise learning from data is the basis of Bayesian statistics and of many modern methods of machine learning and diagnostics.
How do you calculate the denominator P(B) in Bayes theorem?+
You usually determine the denominator P(B), also called the evidence, via the law of total probability. You consider all ways in which the event B can occur and add their probabilities: P(B) = P(B|A)·P(A) + P(B|¬A)·P(¬A). The first term captures the cases where B occurs together with A, the second the cases with the complementary event ¬A. For a test these are the true positives plus the false positives. This denominator is often the decisive and easily overlooked step. Without it you do not get a valid probability, because otherwise the sum of all possibilities does not equal one.
Retain Bayes' Theorem for exams
Create a curated FSRS exam set for P(A|B) = P(B|A)·P(A) / P(B): formula recall, variables, derivation, rearrangement, worked example, common mistakes and exam context.
Free · curated formula set · LaTeX · FSRS spaced repetition
How do you calculate with Bayes' Theorem?
Here is how to work through a typical Bayes' Theorem (P(A|B) = P(B|A)·P(A) / P(B)) task step by step:
- 1
Task
Why is the base rate important?
Solution path
P(A) scales the numerator; rare events can remain unlikely despite a good test.