Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Bayes' Theorem Calculator

How to use Bayes' Theorem Calculator
  1. Pick a mode under Calculation Mode: General Bayes' Theorem, Medical Test or Multiple Hypotheses; the input card and the example box change with it. Learn more about the modes
  2. In General mode type P(A), P(B|A) and P(B|A'), each between 0 and 1. Learn more about the general inputs
  3. In Medical Test mode type the Disease Prevalence, the Sensitivity and the Specificity. Learn more about the medical inputs
  4. In Multiple Hypotheses mode set the Number of Hypotheses (2-6) and type a prior and a conditional probability for each row; the priors must sum to 1. Learn more about the hypotheses
  5. Click Calculate; the posterior appears in the result card with the smaller cards and the tree diagram, or a red box lists the problems. Reset clears every mode. Learn more about the results
  6. Expand the headers of the Step-by-Step Solution to follow the arithmetic, and read the panel on the right for the formula of the current mode. Learn more about the steps

Calculate posterior probabilities using Bayes' Theorem with visual tree diagrams and step-by-step solutions.

Input Probabilities

Base probability that event A occurs
Probability of B given A is true
Probability of B given A is false
💡 Example: Rare Disease Test
• P(A) = 0.01 (disease affects 1% of population)
• P(B|A) = 0.95 (test is 95% accurate if you have disease)
• P(B|A') = 0.05 (5% false positive rate)
🎯
Ready to Calculate
Enter your probabilities and click Calculate to see Bayes' Theorem in action
📊
Visualization Ready
Tree diagram will appear here after calculation

General Bayes' Theorem

Turns P(BmidA)P(B mid A) into P(AmidB)P(A mid B): the prior P(A)P(A) is weighted by the likelihood P(BmidA)P(B mid A) and divided by the total probability P(B)=P(BmidA)P(A)+P(BmidA′)P(A′)P(B) = P(B mid A)P(A) + P(B mid A')P(A'). Learn more about Bayes' theorem













Selecting Your Calculation Mode

DemoThe three modes
Step 0 of 3
The calculator offers three specialized modes tailored to different Bayes' Theorem applications. General Bayes' Theorem mode works with abstract events A and B, requiring prior probability P(A), conditional probability P(B|A), and P(B|A'). This mode suits any scenario where you're updating beliefs based on new evidence.

Medical Test mode simplifies diagnostic probability calculations. Instead of abstract notation, you enter disease prevalence, test sensitivity (true positive rate), and specificity (true negative rate). The calculator automatically computes false positive rate and determines the probability of actually having the disease given a positive test result.

Multiple Hypotheses mode extends Bayes' Theorem to compare 2-6 competing theories simultaneously. Enter prior probabilities and conditional probabilities for each hypothesis. The calculator updates all hypotheses based on observed evidence and ranks them by posterior probability. This mode excels for comparing multiple explanations or scenarios.
The three buttons sit under Calculation Mode at the top of the card, each with a one-line description; the input card's heading changes with the mode, "Input Probabilities", "Test Parameters" or "Hypotheses", and an example box under the buttons shows typical values. Switching mode keeps the numbers typed in the other modes. The three forms of the theorem are explained in What is Bayes' Theorem?, The Medical Test Form of Bayes' Theorem and Bayes' Theorem with Several Hypotheses.

Entering Probabilities in General Mode

DemoThe rare-disease example, a larger prior, Reset
Step 0 of 3
General mode requires three probability inputs, all between 0 and 1. P(A) represents the prior probability—your initial belief that event A is true before observing any evidence. For a rare disease affecting 1% of the population, enter 0.01.

P(B|A) specifies the conditional probability of observing evidence B when A is true. If a medical test correctly identifies disease 95% of the time, enter 0.95. This represents how strongly B indicates A.

P(B|A') gives the conditional probability of observing B when A is false. For the medical test, if false positive rate is 5%, enter 0.05. This quantifies how often B occurs even without A. The calculator uses these three values to compute posterior probability P(A|B)—the updated probability of A given that you've observed B.
Each box takes a value from 00 to 11. A value outside that range, or a box left empty, is reported at Calculate time with "P(A) must be between 0 and 1" or the message of its sibling box. With P(A)=0.01P(A) = 0.01, P(B∣A)=0.95P(B \mid A) = 0.95 and P(B∣A′)=0.05P(B \mid A') = 0.05 the posterior is P(A∣B)=16.10%P(A \mid B) = 16.10\%, with P(B)=5.90%P(B) = 5.90\%, prior odds 0.010.01 and a likelihood ratio of 19.0019.00; raising the prior to P(A)=0.5P(A) = 0.5 lifts the posterior to 95.00%95.00\%. The formula behind the three numbers is in What is Bayes' Theorem?.

Using the Medical Test Calculator

DemoA rare disease, then a common one
Step 0 of 3
Medical test mode uses domain-specific terminology familiar to healthcare applications. Disease Prevalence equals P(Disease)—the base rate in the population being tested. For a cancer affecting 1 in 1,000 people, enter 0.001.

Sensitivity measures the true positive rate: P(Positive Test|Disease). A sensitivity of 0.90 means the test correctly identifies 90% of actual cases. Higher sensitivity reduces false negatives—sick patients who test negative.

Specificity measures the true negative rate: P(Negative Test|No Disease). A specificity of 0.95 means the test correctly identifies 95% of healthy individuals. The calculator automatically computes false positive rate as 1 minus specificity. Results show P(Disease|Positive Test)—the crucial probability that a positive test actually indicates disease, which is often surprisingly low when prevalence is rare.
With prevalence 0.010.01, sensitivity 0.900.90 and specificity 0.950.95 the result reads P(Disease∣Positive Test)=15.38%P(\text{Disease} \mid \text{Positive Test}) = 15.38\% and P(No Disease∣+)=84.62%P(\text{No Disease} \mid +) = 84.62\%; a prevalence of 0.10.1 raises the first to 66.67%66.67\%. A value above 11 or an empty box is reported at Calculate time as "Prevalence must be between 0 and 1" or the message of its sibling box. Why a positive test on a rare disease stays unconvincing is explained in The Medical Test Form of Bayes' Theorem.

Setting Up Multiple Hypotheses

DemoThree hypotheses, a fourth row, priors that do not sum to 1
Step 0 of 3
Multiple hypotheses mode accommodates 2-6 competing theories. First, set the number of hypotheses in the Number of Hypotheses (2-6) box; rows are added or removed to match, and the values already typed stay in place. Each hypothesis gets a name (H₁, H₂, etc.) and requires two probabilities.

Prior Probability P(Hᵢ) represents your initial belief in each hypothesis before observing evidence. These priors must sum to exactly 1.0. For three equally likely theories, use 0.333, 0.333, 0.334. For theories with different plausibility, weight accordingly: perhaps 0.5, 0.3, 0.2.

Conditional Probability P(E|Hᵢ) specifies how likely the observed evidence is under each hypothesis. If evidence E strongly supports H₁, that conditional probability might be 0.8, while H₂ gets 0.4 and H₃ gets 0.2. The calculator updates all hypotheses simultaneously, showing which theory the evidence favors most.
With priors 0.50.5, 0.30.3, 0.20.2 and likelihoods 0.80.8, 0.60.6, 0.40.4 the posteriors are 60.61%60.61\%, 27.27%27.27\% and 12.12%12.12\% with P(E)=66.00%P(E) = 66.00\%. Priors that do not add up are refused at Calculate time with "Prior probabilities must sum to 1 (currently sum to …)". The general form of the update is in Bayes' Theorem with Several Hypotheses.

Reading Results and Tree Diagrams

DemoThe result cards and the tree in two modes
Step 0 of 3
Results display prominently at the top with the posterior probability—the main answer showing updated belief after observing evidence. The percentage indicates how likely event A or disease actually is given the observed evidence B or positive test. Color coding highlights significance: red for low probabilities, blue for moderate, green for high.

The probability tree diagram visualizes the calculation structure. Branches show prior probabilities splitting into conditional paths. Green and orange paths highlight the routes leading to observed evidence. Joint probabilities appear at branch endpoints, showing P(A∩B) for each combination.

Additional metrics include Prior Odds (P(A)/P(A')), Likelihood Ratio (P(B|A)/P(B|A')), and Posterior Odds. These odds-based formulations provide alternative perspectives on how evidence updates beliefs. The likelihood ratio quantifies evidence strength—ratios above 1 support A, below 1 oppose it.
Before the first Calculate the result area reads "Ready to Calculate" and the diagram area "Visualization Ready"; after it, the main card is headed Posterior Probability in general mode and Test Result in medical mode, with a short verdict such as "(Low probability)" under the percentage, and the four smaller cards give P(A′∣B)P(A' \mid B), P(B)P(B), the prior odds and the likelihood ratio. In Multiple Hypotheses mode the result lists every hypothesis with a bar from prior to posterior and names the most likely one. What the odds and the ratio measure is explained in Likelihood Ratios and Odds.

Interpreting Step-by-Step Solutions

DemoOpening the steps
Step 0 of 3
The step-by-step section breaks the calculation into expandable stages. Click any step header to reveal detailed arithmetic. Given Information lists all inputs with proper notation. Step 1 calculates P(A'), the complement probability (1 - P(A)).

Step 2 applies the Law of Total Probability to find P(B): the total probability of observing evidence across all scenarios. This equals P(B|A) × P(A) + P(B|A') × P(A'), summing probability across both A true and A false branches.

Step 3 executes Bayes' Theorem itself: P(A|B) = [P(B|A) × P(A)] / P(B). The numerator weights the prior by how well A predicts B. The denominator normalizes by total evidence probability. Step 4 computes P(A'|B) as 1 - P(A|B), ensuring probabilities sum to 1. Additional Insights show the odds formulation, demonstrating that posterior odds equal prior odds multiplied by likelihood ratio.
The headers read Given Information, Step 1: Calculate P(A'), Step 2: Calculate P(B) using Law of Total Probability, Step 3: Apply Bayes' Theorem to find P(A|B), Step 4: Calculate P(A'|B) and Additional Insights: Odds Form; in Multiple Hypotheses mode there are three steps, ending with a verification that the posteriors sum to one. The law used in step 2 is explained in What is Bayes' Theorem? and taught in The law of total probability.

What is Bayes' Theorem?

Bayes' Theorem is a fundamental formula for updating probabilities based on new evidence. Mathematically: P(A∣B)=P(B∣A)×P(A)P(B)P(A|B) = \frac{P(B|A) \times P(A)}{P(B)}. It answers the question: given that I've observed B, what's the probability that A is true?

The theorem reverses conditional probabilities. If you know P(B|A) (probability of evidence given hypothesis), Bayes' Theorem calculates P(A|B) (probability of hypothesis given evidence). This reversal is crucial because we observe evidence and want to infer causes, but direct knowledge often flows the opposite direction.

The formula combines three components: the prior P(A) representing initial belief, the likelihood P(B|A) measuring how well A predicts the evidence, and the marginal probability P(B) normalizing the result. Stronger evidence (higher likelihood ratio) produces larger updates from prior to posterior.

For comprehensive theory on Bayes' Theorem including proofs, derivations, and applications, see Bayes' theorem.

The lesson states the theorem in words in Bayes' theorem in words, derives it from Conditional probability and works examples in Examples.

The Medical Test Form of Bayes' Theorem

The Medical Test mode is Bayes' theorem with the three inputs renamed: the prevalence is the prior P(D)P(D), the sensitivity is P(+∣D)P(+ \mid D), and the specificity is P(−∣D′)P(- \mid D'), so the false positive rate is 1−specificity1 - \text{specificity}. The posterior is P(D∣+)=P(+∣D) P(D)P(+∣D) P(D)+P(+∣D′) P(D′)P(D \mid +) = \frac{P(+ \mid D)\,P(D)}{P(+ \mid D)\,P(D) + P(+ \mid D')\,P(D')}.

With prevalence 0.010.01, sensitivity 0.900.90 and specificity 0.950.95: the numerator is 0.0090.009, the false positives contribute 0.05⋅0.99=0.04950.05 \cdot 0.99 = 0.0495, so P(+)=0.0585P(+) = 0.0585 and P(D∣+)=0.009/0.0585≈15.38%P(D \mid +) = 0.009 / 0.0585 \approx 15.38\%. Only one positive in six or seven is a true case, because the healthy majority produces more false positives than the sick minority produces true ones. Raising the prevalence to 0.10.1 lifts the posterior to 66.67%66.67\%. The common mistake is to read the sensitivity, 90%90\%, as the chance of having the disease after a positive test; that confuses P(+∣D)P(+ \mid D) with P(D∣+)P(D \mid +).

See Examples and Why Bayes' theorem matters in the lesson, and The law of total probability for the denominator.

Bayes' Theorem with Several Hypotheses

When evidence EE bears on several competing hypotheses H1,…,HnH_1, \ldots, H_n whose priors add up to 11, Bayes' theorem updates all of them at once: P(Hi∣E)=P(E∣Hi) P(Hi)P(E)P(H_i \mid E) = \frac{P(E \mid H_i)\,P(H_i)}{P(E)} with P(E)=∑jP(E∣Hj) P(Hj)P(E) = \sum_j P(E \mid H_j)\,P(H_j) by the law of total probability. Every posterior is the hypothesis's share of the total evidence probability, so the posteriors add up to 11 again.

With priors 0.50.5, 0.30.3, 0.20.2 and likelihoods 0.80.8, 0.60.6, 0.40.4: the products are 0.400.40, 0.180.18 and 0.080.08, their sum is P(E)=0.66P(E) = 0.66, and the posteriors are 60.61%60.61\%, 27.27%27.27\% and 12.12%12.12\%. The ranking can change: a hypothesis with a small prior but a high likelihood can overtake one that started ahead. The common mistake is to enter priors that do not sum to 11, which the calculator refuses; the second is to forget that the likelihoods need not sum to anything, since each is a probability under a different hypothesis.

See Bayes' theorem and total probability and The chain rule in the lesson, and Bayes' theorem in the total probability lesson.

Understanding Prior and Posterior Probabilities

The prior probability P(A) represents belief before observing evidence—the base rate or initial plausibility. In medical testing, prior equals disease prevalence. In hypothesis testing, prior reflects background knowledge about each theory's likelihood. Priors incorporate existing information before the current observation.

The posterior probability P(A|B) represents updated belief after observing evidence B. It combines prior belief with new information. The posterior becomes the new prior for subsequent updates—Bayesian inference proceeds iteratively, refining probabilities as more evidence accumulates.

The shift from prior to posterior quantifies learning. If posterior equals prior, evidence was uninformative. If posterior greatly exceeds prior, evidence strongly supports A. If posterior falls below prior, evidence argues against A. The magnitude of change depends on both evidence strength (likelihood ratio) and how surprising the evidence is (marginal probability P(B)).

The lesson explains why the update matters in Why Bayes' theorem matters and lists the slips to avoid in Common mistakes.

Likelihood Ratios and Odds

The likelihood ratio equals P(B|A) / P(B|A'), comparing how much more likely evidence is under A versus not-A. A likelihood ratio of 10 means evidence is 10 times more likely if A is true. Ratios above 1 support A, below 1 oppose A, exactly 1 is uninformative.

Odds express probability as ratios rather than fractions. Prior odds = P(A) / P(A'), posterior odds = P(A|B) / P(A'|B). Bayes' Theorem in odds form states: posterior odds = prior odds × likelihood ratio. This multiplicative relationship shows how evidence scales belief.

Converting between probability and odds: odds = p / (1-p), probability = odds / (1+odds). Odds of 3:1 correspond to probability 0.75. The odds formulation clarifies that weak evidence (likelihood ratio near 1) barely changes odds, while strong evidence (extreme likelihood ratios) dramatically shifts belief regardless of prior.

The odds form and its connections are covered in The formula and Connections.