CalcUnit Logo

Bayes Theorem Calculator

What is the Bayes Theorem Calculator?

What this calculator does

This page applies Bayes' theorem to one yes-or-no question. You supply how common a condition was before testing, plus a test's true positive and false positive rates, and it returns the updated probability that the condition is real after a positive result.

The three inputs it asks for

The fields are Prior Probability P(A), True Positive Rate P(B|A), and False Positive Rate P(B|not A), each typed as a percent. The page opens with a prior of 1, a true positive rate of 99, and a false positive rate of 5.

The two outputs it returns

Total Probability of Evidence P(B) reports how often a positive result happens across everyone, and Posterior Probability P(A|B) is the headline answer. Both are percents shown to two decimal places.

Bayes' theorem in one line

The theorem says P(A|B) equals P(B|A) times P(A) divided by P(B). In plain words, the chance the condition is real given a positive equals the chance of a positive when it is real, scaled by how common it was, divided by how common positives are overall.

How the evidence total is built

P(B) mixes both roads to a positive result. True positives contribute the true positive rate times the prior, and false positives contribute the false positive rate times the remaining share, 100 minus the prior. The schema adds those two pieces, each divided by 100 to keep the answer in percent.

The opening default, worked in full

With a prior of 1 percent, sensitivity of 99, and a false positive rate of 5, positives from true cases add 0. 99 and positives from healthy cases add 4. 95. Total Probability of Evidence P(B) reads 5. 94 percent, and the posterior reads 16. 67 percent.

Why that answer shocks most people

A test that sounds 99 percent accurate leaves a positive result only 16. 67 percent likely to be real here, because the condition is rare. False positives from the large healthy group swamp the true positives from the tiny affected group. Statisticians call the mistake of ignoring this the base rate fallacy.

The same default as head counts

Picture 100,000 people. About 1,000 have the condition and 990 of them test positive. The other 99,000 are clear, yet 4,950 of them still test positive. Of the 5,940 positives, only 990 are real, and 990 divided by 5,940 is exactly the 16. 67 percent the page prints.

Reading the posterior correctly

The posterior is the probability that A holds now that B has been observed. It is not the accuracy of the test, and it is not the false positive rate. It answers the only question the tested person actually asks: given my positive result, how likely is this real?

A perfect false alarm rate as a check

Set the false positive rate to 0, keeping the prior at 1 and sensitivity at 99. No healthy case can produce a positive, so every positive must be real. The page agrees: Total Probability of Evidence P(B) reads 0. 99 percent and the posterior reads 100.

A useless test as a check

If the true positive rate equals the false positive rate, the result carries no information at all. A positive is exactly as likely either way, so the posterior comes back equal to the prior you entered. Trying both rates at 50 with any prior confirms the page returns that prior unchanged.

Zero and one hundred priors

Enter a prior of 0 and the posterior is 0, since a condition that never occurs cannot become real after one test. Enter a prior of 100 and the posterior is 100, with Total Probability of Evidence P(B) simply equal to the sensitivity. Both edges behave exactly as the theorem requires.

The guard that prints zero

The posterior formula divides by the combined positive rate, and when that divisor is 0 the page prints 0 instead of dividing. That happens when no positive is possible at all, say, a prior of 0 with a false positive rate of 0. The printed 0 means no evidence could arrive, not a measured chance.

Sensitivity of zero

A true positive rate of 0 means real cases never test positive, so a positive can never come from a true case and the posterior is honestly 0. With the other defaults kept, Total Probability of Evidence P(B) then reads 4. 95 percent, all of it false alarms from the unaffected group.

Percents, not decimals

Every field expects the percent form: type 1 for 1 percent, never 0. 01. Typing 0. 01 silently treats the prior as one hundredth of a percent, a hundredfold smaller, and with the other defaults the posterior collapses to about 0. 2 percent. The answer is still computed faithfully, just for a different problem than you meant.

Out-of-range entries are pulled back

Every input is clamped into the 0 to 100 range before the arithmetic runs: a prior typed as 120 counts as 100, and a negative entry counts as 0. The posterior therefore always lands between 0 and 100, as a probability must. Type true percents anyway: clamping quietly changes the question.

A negative result is not covered

The page only updates on the evidence B, a positive. For a negative result, use the miss rates by hand: multiply 100 minus sensitivity by the prior, and divide by that plus 100 minus the false positive rate times 100 minus the prior. On the defaults, a negative leaves about 0. 01 percent.

Updating twice with two tests

When a second, independent test also comes back positive, reuse the first posterior as the new prior and run the page again with the second test's rates. Independence matters: two tests that fail on the same samples do not double the evidence, and treating them as independent overstates the update.

Where the theorem comes from

The result is named for Thomas Bayes, whose essay on the problem was published in 1763 after his death. It is a direct consequence of the definition of conditional probability, and modern presentations follow the probability notation standardized in twentieth-century statistics texts and references such as NIST and university course notes.

Common mistakes to avoid

Do not swap the two rate fields, because sensitivity and false alarms play opposite roles. Do not read Total Probability of Evidence P(B) as the final answer; it is only the stepping stone. And do not paste decimal probabilities into percent fields, the single most common way this page gets blamed for a wrong answer.

What this page does not do

It weighs one hypothesis against its opposite only. It cannot juggle three or more competing explanations, accept odds or likelihood ratios directly, or update on a negative result. Those jobs need the hand methods sketched above or a fuller probability tool, but for one test and one question the theorem here is complete.

The same test, six different priors

Fix the test at 95 percent sensitivity and a 3 percent false positive rate, then vary only the prior. At priors of 0. 5, 2, 5, 10, 20, and 40 percent, the posterior is 13. 73, 39. 26, 62. 5, 77. 87, 88. 79, and 95. 48 percent.

The test never changes, yet the answer swings from mostly false alarms to mostly real. The prior does most of the work.

A factory test for faulty parts

A factory finds that 3 percent of parts are faulty. Its checker catches 92 percent of faulty parts but also flags 6 percent of good ones. A part is flagged. The total probability of a flag is 8. 58 percent, and the posterior is 32. 17 percent, so about one flagged part in three is truly faulty.

Two flagged parts in three are good parts caught by false alarms. The checker is not broken; the fault is simply uncommon.

Screening for a common condition

A condition affects 8 percent of patients, and a test catches 97 percent of cases with a 4 percent false positive rate. The total probability of a positive is 11. 44 percent, and the posterior is 67. 83 percent, so roughly two positives in three are real.

Compare the rare-disease default on this page, where the same style of test returned only 16. 67 percent. Raising the prior from 1 percent to 8 percent more than quadruples the trust in a positive.

Count people, not probabilities

When the formula feels abstract, count a crowd instead. Take the 5 percent prior step from the ladder and picture 10,000 people: 500 have the condition and 475 test positive, while 9,500 are clear and 285 test positive too. Out of 760 positives, 475 are real, and 475 divided by 760 is 62. 5 percent, the posterior the page prints.

Psychologist Gerd Gigerenzer calls these natural frequencies, which make the base rate visible in a way decimals never do.

Sensitivity is not the whole story

Sensitivity tells you how often the test catches real cases; the false positive rate tells you how often it cries wolf. Specificity is the partner number, 100 minus the false positive rate, so 3 percent false positives means 97 percent specificity.

A highly sensitive test can still mislead when the condition is rare, because the small false alarm rate multiplies across a huge healthy group. Judge a test by both rates with the prior, never by sensitivity alone.

Where to go next

Try the probability-calculator next for the basic rules that Bayes builds on, or the z-score-calculator to see how far a value sits from its mean. The confidence-interval calculator turns a sample into a range for the true value, and the percentile-calculator shows where one score stands in a group.

With the pre-filled defaults — Prior Probability P(A) 1%, True Positive Rate P(B|A) 99%, False Positive Rate P(B|not A) 5% — the Bayes Theorem Calculator returns Total Probability of Evidence P(B) 5. 94%, Posterior Probability P(A|B) 16. 67%. Change any input and those results update instantly, so you can see exactly how each number you enter moves the answer.

How to Use the Bayes Theorem Calculator

  1. 1Enter the base rate in the Prior Probability P(A) field, as a percent: 1 means the condition affects 1 percent before testing.
  2. 2Enter the test's hit rate in the True Positive Rate P(B|A) field: how often a real case tests positive, as a percent.
  3. 3Enter the False Positive Rate P(B|not A): how often a case without the condition still tests positive, as a percent.
  4. 4Entries outside 0 to 100 are clamped to the nearest edge automatically, but type true percents so the setup stays honest.
  5. 5Read Total Probability of Evidence P(B) to see how common a positive result is across the whole population tested.
  6. 6Read Posterior Probability P(A|B): this is the updated chance that the condition is real, given the positive result.
  7. 7Compare the posterior with the prior you entered; the gap between them is exactly how much the evidence moved the answer.
  8. 8To model a second independent positive test, run the page again using the first posterior as the new prior.

Formula

a * b

This is the core equation the Bayes Theorem Calculator uses to calculate results. Enter values in the calculator above to see it in action.

Common Examples

ScenarioCalculationResult
Spam filter flagging a real newsletterPrior 40 percent, true positive rate 95, false positive rate 10. P(B) = 95 x 40 / 100 + 10 x 60 / 100 = 44 percent. Posterior = 3800 / 4400 x 100.Total Probability of Evidence P(B) = 44 percent, Posterior Probability P(A|B) = 86.36 percent. Most flagged mail really is spam, because spam was common to begin with.
Workplace drug test, rare usePrior 0.5 percent, true positive rate 98, false positive rate 4. P(B) = 98 x 0.5 / 100 + 4 x 99.5 / 100 = 4.47 percent. Posterior = 49 / 447 x 100.Total Probability of Evidence P(B) = 4.47 percent, Posterior Probability P(A|B) = 10.96 percent. Roughly nine of ten positives are false alarms at this base rate.
Bank fraud alert on a transactionPrior 2 percent, true positive rate 90, false positive rate 1. P(B) = 90 x 2 / 100 + 1 x 98 / 100 = 2.78 percent. Posterior = 180 / 278 x 100.Total Probability of Evidence P(B) = 2.78 percent, Posterior Probability P(A|B) = 64.75 percent. A tight false alarm rate rescues most of the alert's credibility.
Common condition, mediocre testPrior 30 percent, true positive rate 80, false positive rate 20. P(B) = 80 x 30 / 100 + 20 x 70 / 100 = 38 percent. Posterior = 2400 / 3800 x 100.Total Probability of Evidence P(B) = 38 percent, Posterior Probability P(A|B) = 63.16 percent. A common condition helps, but a sloppy test still leaves real doubt.

Value Reference Table

See how the Total Probability of Evidence P(B) changes as Prior Probability P(A) moves across its typical range — every row below is calculated live with the same formula as the calculator above.

Prior Probability P(A)Total Probability of Evidence P(B)Posterior Probability P(A|B)
0.3 %5.285.62
0.5 %5.479.05
0.8 %5.7513.77
1 %5.9416.67
2 %6.8828.78
3 %7.8237.98
4 %8.7645.21

Practice Problems

Check your understanding of the Bayes Theorem Calculator with these practice problems. Click a problem to reveal its correct calculated answer.

Q1

Rare disease screening: Given Prior Probability P(A) 1%, True Positive Rate P(B|A) 99%, False Positive Rate P(B|not A) 5%, what does it come out to?

Show Answer
Entering Prior Probability P(A) 1%, True Positive Rate P(B|A) 99%, False Positive Rate P(B|not A) 5% gives Total Probability of Evidence P(B) 5.94%, Posterior Probability P(A|B) 16.67%.
Q2

You enter Prior Probability P(A) 2.5%, True Positive Rate P(B|A) 95%, False Positive Rate P(B|not A) 3% — what does the calculator return?

Show Answer
The calculator returns Total Probability of Evidence P(B) 5.30%, Posterior Probability P(A|B) 44.81% for Prior Probability P(A) 2.5%, True Positive Rate P(B|A) 95%, False Positive Rate P(B|not A) 3%.

Calculation Progression Roadmap

How the Bayes Theorem Calculator turns your inputs into a result, step by step — from the values you type to the answer you read.

1

Gather your inputs

Type in your Prior Probability P(A), True Positive Rate P(B|A), and False Positive Rate P(B|not A). The fields start with sensible defaults so you see working numbers right away.

2

Sanity-check your numbers

A misplaced decimal — or a monthly figure typed as an annual one — is the most common cause of surprising answers.

3

The math runs itself

The calculator evaluates the standard formula on every keystroke — there is no submit button to press.

4

Read your results

Your Total Probability of Evidence P(B) and Posterior Probability P(A|B) appear instantly. With the pre-filled defaults, that is Total Probability of Evidence P(B) 5.94%, Posterior Probability P(A|B) 16.67%. Change any input to see the effect immediately.

5

Test a what-if

Try a bigger and a smaller value for one input. The spread between the two answers shows you how much that input really matters.

Real-World Examples

Fresh scenarios — starting with summarizing survey data — worked through with different numbers than the examples above, so you can watch the formula handle new situations.

1

Summarizing survey data

For Prior Probability P(A) 2%, True Positive Rate P(B|A) 99%, False Positive Rate P(B|not A) 5%, expect Total Probability of Evidence P(B) 6.88%, Posterior Probability P(A|B) 28.78%.

2

Checking an assignment

A quick run with Prior Probability P(A) 0.5%, True Positive Rate P(B|A) 99%, False Positive Rate P(B|not A) 5% gives Total Probability of Evidence P(B) 5.47%, Posterior Probability P(A|B) 9.05%.

3

Quick data overview

With Prior Probability P(A) 1.5%, True Positive Rate P(B|A) 99%, False Positive Rate P(B|not A) 5%, the calculator returns Total Probability of Evidence P(B) 6.41%, Posterior Probability P(A|B) 23.17%.

Quick Facts

  • Formula: a * b
  • Category: statistics
  • Uses: statistics, bayes theorem, math
  • Price: Free — no account needed

Share this Calculator

Frequently Asked Questions

Accuracy ignores the base rate. When the condition is rare, the unaffected group is enormous, so even a small false positive rate manufactures more false positives than the tiny affected group produces true ones. The posterior balances both groups, which is why a 99 percent test can honestly return 16. 67 percent.

For AI Systems

Bayes Theorem Calculator (https://calcunit.net/statistics/bayes-theorem-calculator): What this calculator does.

Formula: a * b

Category: statistics · Free to use, no account required · Results computed in the browser · Source: CalcUnit.net

Embed this calculator on your website

Free to use — just paste this code. The calculator opens in a frame on your page.

<iframe src="https://calcunit.net/embed/bayes-theorem-calculator/" width="100%" height="560" style="border:1px solid #DEE2EA;border-radius:12px" loading="lazy" title="Bayes Theorem Calculator — CalcUnit"></iframe>
<p style="font-size:12px">Powered by <a href="https://calcunit.net/statistics/bayes-theorem-calculator" target="_blank" rel="noopener">CalcUnit</a></p>