Bayes Theorem Calculator

Calculate posterior probability P(A given B) using prior, likelihood, and false-positive rate

Apply Bayes theorem.

Bayes theorem updates a prior probability after new evidence appears:

P(A | B) = P(B | A)P(A) / [P(B | A)P(A) + P(B | not A)P(not A)]

This is useful for diagnostic tests, spam filters, risk scoring, and evidence-based decision making.

Example Results

1 examples

Update disease probability after a positive test

Use base rate, sensitivity, and false-positive rate to calculate posterior probability.

{
  "result": {
    "posteriorProbability": 0.1667,
    "posteriorPercent": 16.6667
  }
}
View input parameters
{ "priorProbability": 1, "likelihood": 99, "falsePositiveRate": 5, "inputScale": "percent", "decimalPlaces": 4 }

Key Facts

Category
Math, Date & Finance
Input Types
number, select
Output Type
json
Sample Coverage
1
API Ready
Yes

Overview

The Bayes Theorem Calculator allows you to determine the posterior probability of an event by updating its prior probability with new evidence. By inputting the base rate, likelihood (true positive rate), and false-positive rate, you can quickly evaluate the real-world accuracy of diagnostic tests, spam filters, and risk assessments without manually calculating complex conditional probability formulas.

When to Use

  • Evaluating the actual probability of having a condition after receiving a positive medical test result.
  • Updating risk models or fraud detection algorithms when new behavioral evidence is observed.
  • Solving statistics and probability problems that require applying Bayes' theorem to conditional probabilities.

How It Works

  • Enter the prior probability (base rate) of the event occurring before any evidence is known.
  • Input the likelihood (true positive rate) and the false-positive rate of the test or evidence.
  • Select your preferred input scale (percentages or proportions) and set the desired decimal precision.
  • The calculator applies Bayes' theorem to output the updated posterior probability as both a proportion and a percentage.

Use Cases

Medical diagnostics to calculate the true chance of illness given a positive screening test and known disease prevalence.
Machine learning and spam filtering to determine the probability that an email is spam given the presence of specific trigger words.
Quality control in manufacturing to assess the likelihood that a flagged component is actually defective.

Examples

1. Calculating Disease Probability After a Positive Test

Medical Student
Background
A student is analyzing a rare disease that affects 1% of the population. A test for the disease has a 99% true positive rate but a 5% false-positive rate.
Problem
Determine the actual probability that a patient has the disease if they test positive.
How to Use
Set Prior P(A) to 1, Likelihood to 99, and False Positive to 5. Keep the input scale as Percent.
Example Config
Prior: 1, Likelihood: 99, False Positive: 5, Scale: percent
Outcome
The calculator reveals a posterior probability of 16.6667%, demonstrating the base rate fallacy where a positive test does not guarantee the presence of the disease.

2. Updating Spam Probability

Data Scientist
Background
An email filter needs to classify incoming messages. Historically, 20% of all emails are spam. A specific keyword appears in 80% of spam emails, but also in 10% of legitimate emails.
Problem
Calculate the probability that an email is spam if it contains this keyword.
How to Use
Enter 20 for Prior P(A), 80 for Likelihood, and 10 for False Positive Rate.
Example Config
Prior: 20, Likelihood: 80, False Positive: 10, Scale: percent
Outcome
The posterior probability updates to 66.6667%, indicating the email is significantly more likely to be spam when the keyword is present.

Try with Samples

math-&-numbers

FAQ

What is prior probability?

Prior probability, or base rate, is the initial estimated likelihood of an event occurring before any new evidence or test results are considered.

What does likelihood mean in this calculator?

Likelihood represents the true positive rate, or the probability that the evidence (such as a positive test result) appears when the event is actually true.

Why is the posterior probability often lower than expected?

If the prior probability (base rate) is very low, even a highly accurate test with a small false-positive rate will yield a surprisingly low posterior probability. This statistical phenomenon is known as the base rate fallacy.

Can I input values as decimals instead of percentages?

Yes, you can change the Input Scale setting from 'Percent' to 'Proportion' to enter decimal values like 0.01 instead of 1%.

What is the false-positive rate?

The false-positive rate is the probability that the evidence or test result is positive even when the underlying event is false.

API Documentation

Request Endpoint

POST /en/api/tools/bayes-theorem-calculator

Request Parameters

Parameter Name Type Required Description
priorProbability number Yes -
likelihood number Yes -
falsePositiveRate number Yes -
inputScale select No -
decimalPlaces number No -

Response Format

{
  "key": {...},
  "metadata": {
    "key": "value"
  },
  "error": "Error message (optional)",
  "message": "Notification message (optional)"
}
JSON Data: JSON Data

AI MCP Documentation

Add this tool to your MCP server configuration:

{
  "mcpServers": {
    "elysiatools-bayes-theorem-calculator": {
      "name": "bayes-theorem-calculator",
      "description": "Calculate posterior probability P(A given B) using prior, likelihood, and false-positive rate",
      "baseUrl": "https://elysiatools.com/mcp/sse?toolId=bayes-theorem-calculator",
      "command": "",
      "args": [],
      "env": {},
      "isActive": true,
      "type": "sse"
    }
  }
}

You can chain multiple tools, e.g.: `https://elysiatools.com/mcp/sse?toolId=png-to-webp,jpg-to-webp,gif-to-webp`, max 20 tools.

If you encounter any issues, please contact us at [email protected]