Skip to main content
statistics

Bayes' Theorem Calculator

Calculate conditional probability using Bayes' theorem. Determine the posterior probability of a hypothesis given prior knowledge and new evidence from tests or observations.

Reviewed by Chase FloiedUpdated

This free online bayes' theorem calculator provides instant results with no signup required. All calculations run directly in your browser — your data is never sent to a server. Enter your values below and see results update in real time as you type. Perfect for everyday calculations, homework, or professional use.

The initial probability of the hypothesis before observing evidence.

Probability of observing the evidence given the hypothesis is true.

Probability of observing the evidence given the hypothesis is false.

How to Use This Calculator

1

Enter your input values

Fill in all required input fields for the Bayes' Theorem Calculator. Most fields include unit selectors so you can work in your preferred unit system — metric or imperial, whichever matches your problem.

2

Review your inputs

Double-check that all values are correct and that you have selected the right units for each field. Incorrect units are the most common source of calculation errors and can produce results that are off by factors of 2, 10, or more.

3

Read the results

The Bayes' Theorem Calculator instantly computes the output and displays results with units clearly labeled. All calculations happen in your browser — no loading time and no data sent to a server.

4

Explore parameter sensitivity

Try adjusting individual input values to see how the output changes. This is a quick and effective way to develop intuition about how different parameters influence the result and to identify which inputs have the largest effect.

Formula Reference

Bayes' Theorem Calculator Formula

See calculator inputs for the governing equation

Variables: All variables and their units are labeled in the calculator interface above. Input fields accept values in multiple unit systems — select your preferred unit from the dropdown next to each field.

When to Use This Calculator

  • Use the Bayes' Theorem Calculator when you need accurate results quickly without the risk of manual computation errors or unit conversion mistakes.
  • Use it to verify calculations made by hand or in spreadsheets — an independent check can catch errors before they lead to costly decisions.
  • Use it to explore how changing input parameters affects the output — a quick way to develop intuition and identify the most influential variables.
  • Use it when collaborating with others to ensure everyone is working from the same numbers and applying the same assumptions.

About This Calculator

The Bayes' Theorem Calculator is a free, browser-based calculation tool for engineers, students, and technical professionals. Calculate conditional probability using Bayes' theorem. Determine the posterior probability of a hypothesis given prior knowledge and new evidence from tests or observations. It implements standard formulas and supports both metric (SI) and imperial unit systems with automatic unit conversion. All calculations are performed instantly in your browser with no data sent to a server. Use this calculator as a quick reference and sanity-check tool during design, analysis, and learning. Always verify results against primary engineering references and applicable standards for any safety-critical application.

About Bayes' Theorem Calculator

The Bayes' theorem calculator computes the posterior probability of a hypothesis after observing new evidence. Named after Reverend Thomas Bayes, this theorem is the cornerstone of Bayesian statistics and has wide-ranging applications in medical diagnostics, spam filtering, machine learning, forensic science, and decision analysis. The key insight is that the probability of a hypothesis is not fixed but should be updated as new data becomes available. For example, the probability that a patient has a disease changes after a positive test result, and Bayes' theorem quantifies exactly how much it changes by combining the prior probability with the test's sensitivity and false positive rate.

The Math Behind It

Bayes' theorem relates the conditional probability P(A|B) to the reverse conditional P(B|A) through the formula P(A|B) = P(B|A)*P(A)/P(B). The denominator P(B) is computed via the law of total probability: P(B) = P(B|A)*P(A) + P(B|not A)*P(not A). This ensures the posterior probability is properly normalized. The theorem can be understood intuitively: if the prior probability P(A) is very low (a rare disease), even a highly accurate test (high P(B|A), low P(B|not A)) may yield a surprisingly modest posterior probability, because most positive results come from the large pool of healthy individuals. This is known as the base rate fallacy and is one of the most important lessons from Bayesian reasoning. In machine learning, Bayes' theorem underpins Naive Bayes classifiers, which despite their simplicity often perform remarkably well. In Bayesian inference more broadly, the prior is updated sequentially as new data arrives, and with sufficient data the posterior converges regardless of the prior chosen. The theorem generalizes to continuous distributions and multiple hypotheses, forming the basis of Bayesian networks and probabilistic graphical models.

Formula Reference

Bayes' Theorem

P(A|B) = P(B|A) * P(A) / P(B)

Variables: P(A|B) = posterior probability; P(B|A) = likelihood; P(A) = prior; P(B) = total probability of evidence

Worked Examples

Example 1: Medical diagnostic test

A disease affects 1% of the population. A test has 95% sensitivity and 5% false positive rate. What is the probability of having the disease given a positive test?

Step 1:P(A) = 0.01, P(B|A) = 0.95, P(B|not A) = 0.05.
Step 2:P(B) = 0.95*0.01 + 0.05*0.99 = 0.0095 + 0.0495 = 0.059.
Step 3:P(A|B) = (0.95 * 0.01) / 0.059 = 0.161.

Despite a positive test, the probability of actually having the disease is only about 16.1%, because the disease is rare.

Example 2: Email spam filter

5% of emails are spam. The word 'free' appears in 80% of spam and 10% of legitimate emails. What is the probability an email containing 'free' is spam?

Step 1:P(Spam) = 0.05, P(Free|Spam) = 0.80, P(Free|Not Spam) = 0.10.
Step 2:P(Free) = 0.80*0.05 + 0.10*0.95 = 0.04 + 0.095 = 0.135.
Step 3:P(Spam|Free) = (0.80 * 0.05) / 0.135 = 0.296.

An email containing 'free' has about a 29.6% chance of being spam.

Common Mistakes & Tips

  • !Ignoring the base rate (prior probability), which leads to grossly overestimating the posterior after a positive test.
  • !Confusing P(A|B) with P(B|A). The probability of a positive test given disease is not the same as the probability of disease given a positive test.
  • !Forgetting that P(B|not A) contributes significantly to P(B) when P(not A) is large.

Related Concepts

Used in These Calculators

Calculators that build on or apply the concepts from this page:

Frequently Asked Questions

Why does a positive test not guarantee the disease?

Because when a disease is rare, the false positives from the large healthy population can outnumber the true positives from the small diseased population. Bayes' theorem accounts for this base-rate effect.

What is a conjugate prior?

A conjugate prior is a prior distribution that, when combined with a particular likelihood function via Bayes' theorem, produces a posterior distribution in the same family. This simplifies the math considerably.

Can Bayes' theorem handle multiple hypotheses?

Yes. The generalized form divides P(B|Hi)*P(Hi) by the sum of P(B|Hj)*P(Hj) over all hypotheses j. Each hypothesis receives its own posterior probability.