Skip to content
Calcapedia
Statistics & Data

Bayes Theorem Calculator

See how likely something really is after new evidence, such as a positive test, using Bayes' theorem, with the counts shown out of 10,000 people.

Level: Grades 11–12

  • Common Core standard HSS.CP.B.8(+) Apply the general Multiplication Rule in a uniform probability model, P(A and B) = P(A)P(B|A) = P(B)P(A|B), and interpret the answer in terms of the model.
  • Common Core standard HSS.CP.B.6Find the conditional probability of A given B as the fraction of B's outcomes that also belong to A, and interpret the answer in terms of the model.
  • Common Core standard HSS.CP.A.3Understand the conditional probability of A given B as P(A and B)/P(B), and interpret independence of A and B as saying that the conditional probability of A given B is the same as the probability of A, and the conditional probability of B given A is the same as the probability of B.
Printable worksheet

Bayes Theorem Calculator

Know the answer you need? Pick an input to work backward.

Inputs
Enter

The share of the group that has the condition before any test.

Of those with the condition, the share who test positive.

Of those without the condition, the share who still test positive (100% minus the specificity).

Result

Chance of the condition after a positive result, P(A | +)

16.1017%

A positive result raises the chance of the condition from 1% to 16.1017%.

Chance a positive result is a false alarm, P(not A | +)
83.8983%
Share of everyone who tests positive, P(+)
5.9%
Chance of the condition after a negative result, P(A | −)
0.0531%
Chance a negative result is correct, P(not A | −)
99.9469%
Positive likelihood ratio (sensitivity ÷ false positive rate)
19

See the step-by-step solution ↓

Out of 10,000 people
Out of 10,000 people
GroupTest positiveTest negativeTotal
Has the condition955100
Doesn't have it4959,4059,900
Everyone5909,41010,000

Step-by-step solution

  1. Find the chance of having the condition and testing positive: how often the test catches it, times how common it is

    P(A and +)=0.95×0.01=0.0095
  2. Find the chance of a false alarm: the false positive rate, times the share of people without the condition

    P(not A and +)=0.05×1−0.01=0.0495
  3. Add the two, since a positive result can come either way. That is the total chance of testing positive

    P(+)=0.0095+0.0495=0.059
  4. Divide the real positives by all positives to see how many positive results are real (Bayes' theorem)

    P(A | +)=0.00950.059=0.1610169492=16.101695%
  5. After a negative result: divide the missed cases by all negative results

    P(A | −)=0.00050.941=0.0005313496

Test yourself

20 quick questions built from this calculator's formula: work out results, predict what happens when an input changes, and work backward from an answer. Every answer comes with the working.

What this calculator does

Find out how likely something really is once you see new evidence, such as a positive test result. Bayes' theorem does this. It starts with how likely the thing was to begin with, called the base rate or prior. Then it weighs how much more often the evidence shows up when the thing is true than when it's false. The result is the posterior probability, the updated chance. It's often surprisingly different from what your gut says.

The calculator works in two ways. In the screening-test form, enter how common a condition is, how often the test catches it, and how often it gives a false alarm. You get the chance that a positive result is real and the chance after a negative result. A table shows the same numbers out of 10,000 people.

In the general form, enter three probabilities directly to get P(A | B). Read P(A | B) as "the chance of A, given that B happened". P(A) is the chance of A on its own. P(B | A) is the chance of B when A is true, and P(B) is the overall chance of B.

Where it's used

Why this math matters outside the classroom:

  • Screening tests. A test that is 95% sensitive with 5% false positives, used where 1% have a condition, gives a positive result about a 16% chance of being real.
  • Spam filters. A filter sees a word in 40% of spam and 2% of normal mail; if 30% of mail is spam, an email with that word is spam with probability about 0.90.
  • Factory defects. Machine A makes 30% of parts with a 4% defect rate; if 2% of all parts are defective, a defective part came from A with probability 0.6.
  • Weather forecasts. A planner combines a 20% base chance of rain with a radar sign seen before 70% of rainy days and 10% of dry ones to get about 64%.
  • Security alerts. An analyst finds that an alarm firing 1% of the time on safe traffic floods staff with false alerts when real attacks are rare.

Grade level and standards: Grades 11–12; Common Core State Standards for Mathematics HSS.CP.B.8, HSS.CP.B.6, HSS.CP.A.3. © Copyright 2010. National Governors Association Center for Best Practices and Council of Chief State School Officers. All rights reserved.

How to use it

  1. Choose the screening-test form or the general form.
  2. Enter each probability as a percent from 0 to 100.
  3. Read the updated (posterior) probability first. Then see the false-alarm share, the result after a negative test and the likelihood ratio.
  4. Look at the table out of 10,000 people to see where the numbers come from.

What the inputs mean

Base rate: how common the condition is, P(A)
The base rate is how common the condition is in the group being tested, before any test result. The same test gives very different answers in a group where the condition is rare and one where it's common.
True positive rate (sensitivity), P(+ | A)
Of those with the condition, the share who test positive.
False positive rate, P(+ | not A)
The false positive rate is 100% minus the specificity. Specificity is how often the test correctly clears people who don't have the condition. A test that is 95% specific gives false positives 5% of the time.
P(B), overall probability of B
P(B) has to fit with the other two numbers. It must be at least P(B | A) × P(A). And the rest of it has to fit inside the cases where A is false.

Formula and method

P(A | B) = P(B | A) × P(A) ÷ P(B)
P(+) = P(+ | A) × P(A) + P(+ | not A) × (1 − P(A))
P(A | +) = sensitivity × base rate ÷ P(+)
P(A | −) = (1 − sensitivity) × base rate ÷ P(−)
positive likelihood ratio = sensitivity ÷ false positive rate

In the formulas, A is the thing you care about (such as having the condition), and B is the evidence. + means a positive test and − a negative one. The bar | means "given". Sensitivity is how often the test catches people who have the condition.

The multiplication rule says P(A and B) = P(B | A) × P(A). It also says P(A and B) = P(A | B) × P(B). Set the two equal and divide by P(B), and you get Bayes' theorem. In words: of all the cases where B happens, what share also have A?

In a screening test, a positive result can come from two places. Some people have the condition and are correctly flagged. Others don't have it but are flagged anyway. Adding those two gives the overall chance of a positive result (the law of total probability). The posterior is the first group's share of that total.

When the condition is rare, the second group can be much bigger than the first, even for an accurate test. That's because there are so many more people without the condition. This is the base-rate effect. It's why the table of counts out of 10,000 is often the clearest way to see the answer.

Worked example

A condition affects 1% of a group. A screening test flags 95% of people who have it, and wrongly flags 5% of people who don't. If someone tests positive, how likely is it they have the condition?

  1. Out of 10,000 people, 100 have the condition and 9,900 don't.
  2. True positives: 0.95 × 0.01 = 0.0095, or 95 people.
  3. False positives: 0.05 × 0.99 = 0.0495, or 495 people.
  4. Everyone who tests positive: 0.0095 + 0.0495 = 0.059, or 590 people.
  5. P(condition | positive) = 0.0095 ÷ 0.059 = 0.161017.

Result: Only about 16.1017% of positive results are real: 95 of the 590 people who test positive. A negative result, on the other hand, is correct about 99.95% of the time.

Understanding the result

A low posterior after a positive result doesn't mean the test is useless. The result still raised the probability from 1% to about 16%. A second, separate test (using 16% as the new base rate) would raise it much further. Building up evidence step by step is how Bayes' theorem is meant to be used.

The likelihood ratio sums up the test's strength on its own. A ratio of 19 means a positive result is 19 times as likely in someone with the condition as in someone without it. That's true whatever the base rate.

Assumptions and limitations

  • The rates you enter apply to the group in question. The base rate, in particular, depends on who is being tested.
  • In the screening form, the person tested is a typical member of that group.
  • This is a probability tool for learning and planning, not medical, legal or other professional advice. Real figures for how well a test works come from the test's own documentation, and from a professional who can explain them.
  • Only two outcomes (A or not A) are handled. Problems with several competing explanations need the extended form of the theorem.

Frequently asked questions

Why is the posterior so low when the test is 95% accurate?

Because the condition is rare. Among 10,000 people, 5% false positives from the 9,900 healthy people is 495. That's far more than the 95 true positives from the 100 who have the condition. So most positive results come from the large healthy group.

What is the difference between P(A | B) and P(B | A)?

P(B | A) is how often B happens when A is true, such as how often the test is positive for someone with the condition. P(A | B) flips it: how often A is true when B happens. Mixing up the two is a common mistake. Bayes' theorem turns one into the other.

What are the prior and posterior?

The prior is the probability before seeing the evidence (the base rate). The posterior is the updated probability after taking the evidence into account. Today's posterior can be the prior for the next piece of evidence.

How do sensitivity and specificity relate to these inputs?

Sensitivity is the true positive rate, and you enter it directly. Specificity is the true negative rate. The false positive rate is 100% minus the specificity.

How this calculator is checked

Method: Bayes' theorem derived from the general multiplication rule, with P(B) from the law of total probability; posterior after a negative result and the positive likelihood ratio from the same two-by-two table. Checked against the textbook base-rate example (1%, 95%, 5%). The calculation is covered by automated tests with known reference values and edge cases. Last updated 2026-10-18. Found a problem? Tell us.

Embed this calculator

Put this Bayes Theorem Calculator on your own website or blog for free. Paste this code where you want it to appear: