BYTETOOLS

Bayes' Theorem Calculator

Apply Bayes' theorem to get a posterior probability, or switch to diagnostic-test mode for positive and negative predictive value with an expanded 2 × 2 table.

50.0000%
PPV — P(disease | positive)
99.9898%
NPV — P(no disease | negative)
99
Positive likelihood ratio
0.0101
Negative likelihood ratio

Expanded 2 × 2 table for 100,000 people

Has conditionNo conditionRow total
Test positive9909901,980
Test negative1098,01098,020
Column total1,00099,000100,000

Of 1,980 positive results, only 990 actually have the condition — a positive predictive value of 50.0000%. Overall accuracy is 99.0000%, which is why accuracy alone is a misleading headline number for a rare condition.

PPV = (sens × prev) ÷ [sens × prev + (1 − spec) × (1 − prev)] — this is Bayes' theorem with A = “has the condition” and B = “tests positive”. These are illustrative probability estimates, not medical advice; a real test result should always be interpreted by a clinician who knows the specific assay and the patient.

What is the Bayes' Theorem Calculator?

The ByteTools Bayes' Theorem Calculator updates a prior probability in the light of new evidence. In general mode you supply P(A), P(B|A) and P(B|not A) and it returns the posterior P(A|B), along with the prior odds, the likelihood ratio and the posterior odds so you can see the odds form of the theorem as well as the fraction.

  • General Bayes' theorem and diagnostic-test modes in one tool
  • Posterior probability with the full substituted formula shown
  • Prior odds, likelihood ratio and posterior odds
  • Positive and negative predictive value plus both likelihood ratios
  • Expanded 2 × 2 cohort table that makes the base rate visible
  • Everything computed in your browser — nothing is uploaded

How to use the Bayes' Theorem Calculator

  1. 1

    Choose general Bayes' theorem mode or diagnostic-test mode.

  2. 2

    In general mode, enter the prior P(A), the true positive rate P(B|A) and the false positive rate P(B|not A) as percentages.

  3. 3

    In diagnostic mode, enter prevalence, sensitivity and specificity as percentages.

  4. 4

    Read the posterior probability, or the positive and negative predictive values.

  5. 5

    Check the expanded 100,000-person table or the odds-form working, then click Copy results.

About the Bayes' Theorem Calculator

The ByteTools Bayes' Theorem Calculator updates a prior probability in the light of new evidence. In general mode you supply P(A), P(B|A) and P(B|not A) and it returns the posterior P(A|B), along with the prior odds, the likelihood ratio and the posterior odds so you can see the odds form of the theorem as well as the fraction.

Diagnostic-test mode takes the three numbers medical and screening problems are usually stated with — prevalence, sensitivity and specificity — and returns positive and negative predictive value plus both likelihood ratios. It also expands the whole thing into a 2 × 2 table for 100,000 people, which makes the base-rate effect impossible to miss: a 99%-accurate test for a 1%-prevalence condition still gives a positive predictive value of only 50%.

These are illustrative probability estimates for learning and planning, not medical advice, and a real test result should always be interpreted by a clinician who knows the specific assay. All arithmetic runs locally in your browser and nothing you type is uploaded.

Frequently asked questions

How does Bayes' theorem work in plain English?

It rescales your starting belief by how much better the evidence fits one hypothesis than the other. The posterior probability is the probability of the evidence under your hypothesis times the prior, divided by the total probability of seeing that evidence at all.

Why can a 99% accurate test still be wrong half the time?

Because accuracy is not the same as predictive value. If only 1% of people have the condition, testing 100,000 people finds about 990 true positives and about 990 false positives, so a positive result is right only half the time. The base rate matters as much as the test quality.

What is the difference between sensitivity and positive predictive value?

Sensitivity is the probability of a positive test given that you have the condition, which is a property of the test. Positive predictive value is the probability you have the condition given a positive test, which also depends on how common the condition is in the group being tested.

What is a likelihood ratio and why is it useful?

The positive likelihood ratio is sensitivity divided by one minus specificity, and it tells you how many times more likely a positive result is in someone with the condition. It is useful because it does not depend on prevalence, so you can multiply it straight into the prior odds.

Can I use this calculator for something other than medical tests?

Yes. The same maths applies to spam filters, fraud detection, quality control and forensic evidence. Read prevalence as the base rate of the thing you are looking for, sensitivity as the detection rate and specificity as one minus the false alarm rate.

Related tools