Bayes’ Theorem Calculator (Discrete): Probability for High School Statistics

Bayes’ Theorem Calculator

Bayes’ Theorem Calculator

Calculate the posterior probability $P(H|E)$ given the prior, sensitivity, and false positive rate.

Probabilities

The baseline probability of the hypothesis (e.g., disease prevalence).

Sensitivity: Probability of Evidence given Hypothesis is true.

Probability of Evidence given Hypothesis is false.

Load Example: Rare Disease Fair Coin Test Spam Filter

Formula

$$ P(H|E) = \frac{P(E|H)P(H)}{P(E)} $$

Where $P(E) = P(E|H)P(H) + P(E|\neg H)P(\neg H)$

Results

Posterior Probability P(H|E)
–%
Given the evidence, the probability H is true.
Total P(E):
Likelihood Ratio:

Probability Space

True Pos False Pos
Hover over regions for details.

Natural Frequency Interpretation

Understanding Bayes’ Theorem

Bayes’ Theorem describes the probability of an event, based on prior knowledge of conditions that might be related to the event. It is the mathematical formula for updating our beliefs in light of new evidence.

The Base Rate Fallacy

A common mistake for students is ignoring the Prior Probability (Base Rate). For example, if a medical test is 99% accurate, it feels intuitive that a positive result means you are 99% likely to be sick. However, if the disease is extremely rare (e.g., 1 in 10,000), the vast number of “False Positives” from healthy people will drown out the “True Positives” from sick people.

Components

  • Prior $P(H)$: How likely the hypothesis was before seeing evidence.
  • Likelihood $P(E|H)$: How likely the evidence is if the hypothesis is true.
  • Marginal $P(E)$: The total probability of seeing the evidence (from both true and false cases).
  • Posterior $P(H|E)$: The updated probability after seeing the evidence.

FAQ

Why is the result lower than the test accuracy?
If the prior probability (e.g., disease prevalence) is very low, even a highly accurate test can produce a low posterior probability. This is because the population of “negatives” is so large that even a small false positive rate generates many false alarms.
What if P(E|H) and P(E|¬H) sum to 1?
They don’t have to! $P(E|H)$ is the probability of evidence given H is true. $P(E|\neg H)$ is the probability of evidence given H is false. These are conditional probabilities on different conditions, so they are independent numbers. However, $P(E|H) + P(\neg E|H) = 1$.

UNDERGRADUATE