Bayes Theorem Calculator
Use this Bayes Theorem Calculator to find posterior probability from prior probability, likelihood, and false-positive or alternative-event probability. Enter probabilities as percentages, decimals, or fractions, and get a clean step-by-step Bayes theorem solution with formulas.
Calculate Bayes Theorem
Enter the probability of event A, the probability of evidence B given A, and the probability of evidence B given not A. The calculator finds \(P(A|B)\), the updated probability of A after observing B.
What Is a Bayes Theorem Calculator?
A Bayes Theorem Calculator is a probability tool that updates the probability of an event after new evidence is observed. It uses Bayes theorem to calculate a posterior probability, which is the revised probability of a hypothesis after considering evidence. The calculator is useful when you know a prior probability, a likelihood, and the probability of the evidence under an alternative condition.
Bayes theorem is one of the most important ideas in probability, statistics, artificial intelligence, data science, medical testing, risk analysis, machine learning, spam filtering, legal reasoning, diagnostic reasoning, and decision-making. It gives a structured way to revise beliefs when new information arrives. Instead of treating evidence in isolation, Bayes theorem combines the evidence with the original base rate.
For example, suppose a medical condition is rare, but a test for it is very accurate. If someone receives a positive test result, many people assume the probability of having the condition must be almost the same as the test accuracy. Bayes theorem shows why that assumption can be wrong. If the condition is rare, false positives may still be common compared with true positives. The final posterior probability depends on the base rate, test sensitivity, and false-positive rate together.
This calculator is designed to make that reasoning visible. It calculates \(P(A|B)\), which means the probability of event A given evidence B. It also shows \(P(B)\), the total evidence probability, the true-positive part, the false-positive part, and the complement probability \(P(A^c|B)\). The step-by-step section explains every part of the calculation so students and readers can understand the result, not just copy an answer.
How to Use the Bayes Theorem Calculator
Start by entering the prior probability \(P(A)\). This is the probability of the event before the new evidence is known. For example, if 1 out of 100 people in a population has a condition, the prior probability is 1%, 0.01, or 1/100. The calculator accepts all three formats.
Next, enter the likelihood \(P(B|A)\). This is the probability of seeing the evidence if event A is true. In a medical-test example, this may be the sensitivity of the test: the probability that the test is positive when the person truly has the condition. In a spam-filter example, it may be the probability that an email contains a specific word if the email is spam.
Then enter the alternative likelihood \(P(B|A^c)\). This is the probability of seeing the same evidence when event A is not true. In a medical-test example, this is the false-positive rate: the probability that the test is positive even though the person does not have the condition. In a fraud example, this might be the chance that a normal transaction still triggers a suspicious signal.
Choose how many decimal places should appear in the result and click the calculate button. The calculator returns the posterior probability \(P(A|B)\), the probability of the evidence \(P(B)\), the complement probability, and all calculation steps. A percentage bar compares the prior and posterior probability so the update is visually clear.
Bayes Theorem Calculator Formulas
The standard Bayes theorem formula is:
When the evidence \(B\) can occur under event A or under the complement of A, the denominator can be expanded using the law of total probability:
The complement of A is:
Substituting the total probability formula into Bayes theorem gives the calculator’s main formula:
The posterior complement can also be calculated:
Prior, Likelihood, Evidence, and Posterior
Bayes theorem becomes easier when each term has a clear meaning. The prior probability is the starting probability before the evidence is considered. It is written as \(P(A)\). The prior may come from historical data, population frequency, previous research, expert estimates, or baseline assumptions.
The likelihood is the probability of the evidence if the hypothesis is true. It is written as \(P(B|A)\). The likelihood measures how strongly the evidence is expected under event A. Strong evidence usually has a high likelihood when A is true and a low likelihood when A is false.
The evidence probability, or marginal probability of evidence, is written as \(P(B)\). It measures how often the evidence occurs overall. In the complement version of Bayes theorem, evidence can arise from true-positive cases and false-positive cases. Both parts must be counted.
The posterior probability is the updated probability after evidence is observed. It is written as \(P(A|B)\). This is usually the answer users want from a Bayes theorem calculator. It answers, “Given that evidence B occurred, what is the probability that A is true?”
| Term | Notation | Meaning |
|---|---|---|
| Prior | \(P(A)\) | Probability of A before observing evidence B. |
| Likelihood | \(P(B|A)\) | Probability of evidence B if A is true. |
| Alternative likelihood | \(P(B|A^c)\) | Probability of evidence B if A is false. |
| Evidence | \(P(B)\) | Total probability that evidence B occurs. |
| Posterior | \(P(A|B)\) | Updated probability of A after observing B. |
Bayes Theorem with a Complement Event
The complement form is the version most users need because many real-world problems involve two possibilities: the event happens or it does not happen. A person has a condition or does not have it. An email is spam or not spam. A transaction is fraudulent or legitimate. A student knows a concept or does not know it. A machine is defective or not defective.
In these cases, the evidence can appear in both groups. A test can be positive for someone with the condition, but it can also be positive for someone without the condition. A fraud alert can occur for a fraudulent transaction, but it can also occur for a legitimate transaction. Bayes theorem forces both pathways to be included in the denominator.
The denominator is often the most important part of the calculation. Many incorrect intuitive answers ignore the false-positive pathway. If the prior probability is low and the false-positive rate is not extremely small, the false-positive part can be large compared with the true-positive part. This is why a high test sensitivity does not automatically imply a high posterior probability when the event is rare.
Common Applications of Bayes Theorem
Bayes theorem appears in many fields because it is a general rule for updating probabilities. In medical testing, it helps estimate the probability that a patient has a condition after a positive or negative test result. It combines prevalence, sensitivity, and false-positive rate.
In machine learning, Bayesian reasoning helps models update predictions as new data arrives. Naive Bayes classifiers are used in text classification, spam filtering, sentiment analysis, and document categorization. In cybersecurity, Bayesian reasoning can help score alerts by combining base rates and signal patterns.
In business and marketing, Bayes theorem can update the probability that a lead will convert after a customer action. In legal and forensic reasoning, it can help explain how evidence changes probability, although it must be used carefully and ethically. In education, Bayesian updating can model whether a student has mastered a skill after answering a question correctly.
Bayes Theorem Worked Examples
Example 1: Suppose a condition affects 1% of a population. A test is positive for 99% of people who have the condition, and it is falsely positive for 5% of people who do not have the condition. We want \(P(A|B)\), the probability that a person has the condition given a positive result.
The true-positive part is \(0.0099\). The false-positive part is \(0.0495\). The total evidence probability is \(0.0594\). Therefore:
This result often surprises people. Even with a very sensitive test, the posterior probability is only about 16.67% because the condition is rare and false positives occur among the much larger group without the condition.
Example 2: Suppose 30% of emails are spam. A certain word appears in 80% of spam emails and 10% of non-spam emails. The probability that an email is spam given that it contains the word is:
Common Bayes Theorem Mistakes
The first common mistake is confusing \(P(A|B)\) with \(P(B|A)\). These are not the same. \(P(B|A)\) is the probability of evidence if the event is true. \(P(A|B)\) is the probability of the event after evidence is observed. Bayes theorem converts one direction into the other using the prior and evidence probability.
The second mistake is ignoring the base rate. Base rate means the original frequency of the event. If an event is rare, even strong evidence may not make the posterior probability extremely high unless the false-positive rate is very low. This is called base-rate neglect.
The third mistake is using percentages and decimals inconsistently. For example, 5% should be entered as 5%, 0.05, or 1/20, not as 5 unless the calculator explicitly treats it as a percentage. This tool accepts percentage signs to reduce that confusion.
The fourth mistake is treating Bayes theorem as proof. Bayes theorem updates probability under the assumptions entered. If the prior, likelihood, or false-positive rate is wrong, the posterior result can also be wrong. Good Bayesian reasoning depends on reliable inputs.
Bayes Theorem Calculator FAQs
What does a Bayes Theorem Calculator do?
It calculates posterior probability, usually written as \(P(A|B)\), by combining prior probability, likelihood, and evidence probability.
What is Bayes theorem?
Bayes theorem is a probability rule that updates the probability of an event after new evidence is observed: \(P(A|B)=\frac{P(B|A)P(A)}{P(B)}\).
What is prior probability?
Prior probability is the probability of an event before observing the new evidence. It is written as \(P(A)\).
What is posterior probability?
Posterior probability is the updated probability after evidence is observed. It is written as \(P(A|B)\).
Can I enter percentages?
Yes. You can enter values like 5%, 0.05, or 1/20. The calculator converts them into probability values.
Why is the posterior sometimes much lower than test accuracy?
Because the posterior depends on the base rate and false-positive rate, not just test sensitivity. Rare events can produce many false positives compared with true positives.
Important Note
This Bayes Theorem Calculator is for education, probability learning, statistics practice, and general reasoning. It is not medical advice, legal advice, financial advice, diagnostic guidance, or a substitute for expert review. Real-world decisions should use verified data, appropriate models, and qualified professional judgment where needed.
