Bayes' Theorem Calculator
Free Bayes' theorem calculator. Update a prior probability with new evidence to find the posterior P(A|B), or solve for any term of Bayes' rule. With worked examples and charts.
https://hexacalculator.com/calculators/mathematics/statistics/bayes-theorem-calculator
Mathematics
Statistics
Bayes' Theorem Calculator
Free Bayes' theorem calculator. Update a prior probability with new evidence to find the posterior P(A|B), or solve for any term of Bayes' rule. With worked examples and charts.
Bayes' Theorem Calculator
What to calculate
Evidence mode: enter how common A is to begin with (the prior), how often the evidence shows up when A is true (the likelihood), and the false-positive rate. The calculator returns the updated probability of A.
Prior and evidence
%
%
Enter specificity instead of the false-positive rate
Specificity is the true-negative rate. The false-positive rate is one minus specificity.
%
%
- P(B) — probability of the evidence
- %
- P(not A | B)
- %
- Likelihood ratio (Bayes factor)
After weighing the evidence, the probability works out to about 16.1017%.
Notice how a low prior keeps the posterior modest even with a strong test. When A is rare, most positive results are false positives. This is the base rate fallacy.
Charts
The Bayes Theorem calculator updates probabilities based on new evidence. It starts with a prior estimate called the "prior probability". Then it takes into account information about how strongly each piece of evidence supports one option or another to give a more accurate estimate called the "posterior probability". This tool can be used in two ways: You can enter prior probabilities, likelihoods and false positive rates to update probabilities like in a diagnostic test. Alternatively you can switch to the classic four element rule calculator and leave any element blank to find the solution.
What is Bayes' Theorem?
Bayes' theorem, also known as Bayes' rule or Bayes' law, is named after the Reverend Thomas Bayes. This 18th-century minister examined conditional probabilities and showed how to update a probability when given new information. The importance of Bayes' theorem in statistics is often compared to that of Pythagoras' theorem in geometry. It has applications in many fields from spam filters and medical screening to search engines, and you may be using it every day without knowing it.
At the heart of this concept is conditional probability. If you're looking for a sock, it's more likely that you'll find one if you've already looked where you normally look. Similarly, your estimate of the chance of rain changes when it's a cloudy morning. Bayes' theorem translates this intuition into a mathematical formula.
Bayes' theorem formula:
In its simplest form, this theorem relates two conditional probabilities. The probability of A given that B has already occurred is represented as P(A|B).
Every point has a name and function.
Term | Name | Meaning |
|---|---|---|
P(A|B) | Posterior | Probability of A after seeing the evidence B |
P(B|A) | Likelihood | Probability of the evidence B when A is true |
P(A) | Prior | Probability of A before any evidence |
P(B) | Marginal | Overall probability of the evidence B |
This rule is symmetrical so the equations can be rearranged and any of the other three points can be calculated. This is the task of the rules mode. If an input field is left blank the calculator will calculate the solution.
A complete example:
If it rains on 20% of days, then the probability of this happening in advance is P(A) = 0.20. On rainy days, there is a 60% chance that it will be cloudy in the morning, so the conditional probability is P(B|A) = 0.60. Overall, on 40% of days, it is cloudy in the morning, so the marginal probability is P(B) = 0.40. The probability that it rains on a cloudy morning is:
This cloudy morning increases the probability of rain from 20% to 30%. This is a one-step Bayesian update.
Extended formula for use in tests.
In general, the total probability of a particular outcome B is not known directly, but how the evidence behaves in each case is known. In testing, one typically knows the sensitivity (or true positive rate) and false positive rate (which is 100% minus specificity, or true negative rate). The law of total probability allows one to reconstruct the total probability P(B) from these components.
When you substitute this denominator into the Bayes' theorem, you get the formula that's used in the context of evidence.
Consider a disease that affects 1% of the population. The probability that a test will detect it in an actual patient is 95%, while the rate of false positives is 5%. A positive result is worrying, but the chance that you actually have the disease is:
The Base Rate Fallacy.
Most people are surprised by the 16% result, and it is due to the base rate fallacy. When a condition is very rare, false positives from the huge number of healthy people will outweigh the few true positives. The base rate fallacy is ignoring the prior probability and interpreting a test result of 95% as being 95% likely to be sick. A graphical representation of positive results for this tool shows this distribution at a glance. The proportion of true positives directly corresponds with the posterior probability.
Bayes' theorem applications
Bayesian updating is not limited to the classroom; it helps doctors turn test results into probabilities of actual diseases and decide whether further tests are needed. Spam filters learn what words appear in spam e-mails, and update the probability that a new message is spam. Court cases, finance, genetics, and search engines all rely on the same rules, combining prior knowledge with new evidence.
How to use this calculator:
Select the mode at top. In the "Evidence" mode, enter the pre-test probability, likelihood, false positive rate or specificity and get the post-test probability, as well as the marginal probability and likelihood ratio. By opening the "Negative Results" option you can see what a negative test result means, including the negative predictive value. In the "Rule" mode, enter three of four items and leave the fourth blank. The calculator will then fill in that item. As any probability can be entered as a percentage, "5 %" and "0.05" mean the same thing.
This tool is for educational and planning purposes only. It assumes that the probabilities entered are correct and independent of each other as described above. For medical or legal decisions, please consult a qualified professional.
Frequently asked questions
- When should you use Bayes' theorem?
Bayes' theorem is used when you know the probability of an event before observing a piece of evidence and want to calculate the updated probability of the event after you've seen the evidence. If you already know the joint probability of two events, then the regular definition of conditional probability suffices.
- What's the difference between prior and posterior probability?
The prior probability is the probability of an event before new evidence is taken into account. An example would be the base rate of a particular disease. The posterior probability is a corrected probability that takes evidence into account. Bayes' theorem is a rule that transforms the prior probability to the posterior probability.
- Why is it unlikely that you are sick even if a test comes back positive?
This is because the condition is rare. If only 1% of people have a disease, then healthy people make up 99%. Because there are so many false positives, they often outnumber the true positives, so that a positive result does not necessarily mean you actually have the disease. This is called "base rate fallacy".
- What is the ratio of probabilities?
The likelihood ratio is the ratio of the sensitivity (probability of a true positive) to the false positive rate (probability of a false positive). It measures how strong the evidence is for a hypothesis. If the ratio is 19, then the probability that a positive result is a true positive is 19 times the probability that it is a false positive.
- Can probabilities be entered as percentages or decimals?
Both are possible. The calculator treats any probability on the screen as a percentage, so entering 5 is the same as entering the probability 0.05. Any value should be between 0 and 100%.
Related calculators






Disclaimer: This calculator is provided for general informational and educational purposes only. Our calculators are under active development, and results may be inaccurate, incomplete, or unsuitable for your situation. Always verify the figures independently and seek advice from a qualified professional before relying on them. We make no warranties and accept no liability for any loss or decision arising from use of this tool.
References
- Bayes' theorem — Wikipedia
Statement, proof, and worked examples of Bayes' theorem, including the medical-test case.
- Bayes's theorem — Encyclopaedia Britannica
Concise reference on the theorem, its terms, and its history.
- Bayes' Theorem — Stanford Encyclopedia of Philosophy
Rigorous treatment of Bayesian updating, priors, likelihoods, and evidence.
- Base rate fallacy — Wikipedia
Why a rare base rate keeps the posterior low despite an accurate test.