Conditional probability
Bayes' Theorem Calculator
Enter P(A), P(B|A), and P(B|¬A) to update P(A|B) after observing B.
Calculation inputs
Enter probabilities as decimals from 0 to 1.
Results
Read the posterior probability after observing B.
Bayes' theorem guide
Update a probability after evidence appears
This calculator uses Bayes' theorem to answer a very specific question: after observing B, how plausible is A now? It combines the prior probability of A with the chance of seeing B when A is true and when A is false, so the base rate does not disappear from the result.
Start by defining A, B, and the three probabilities
The tool uses decimals between 0 and 1. Enter 1% as 0.01 and 90% as 0.9, then calculate to see P(A|B), P(B), and P(¬A|B) in the result panel.
- Define A first. Use A for the hypothesis you want to check, such as a disease being present, a message being spam, or a particular cause being true.
- Define B as the evidence. Use B for the observed result, such as a positive test, a filter warning, or a signal that has appeared.
- Enter all three probabilities. Fill P(A), P(B|A), and P(B|¬A) as values between 0 and 1.
- Read P(A|B). That is the probability of A after B is observed. P(¬A|B) is the remaining probability for not A.
The inputs are one prior probability and two likelihoods
A prior probability is the chance before the new evidence is considered. A likelihood is a probability with a condition attached. Bayes’ theorem needs both, because strong evidence can still be moderated by a low base rate.
P(A)
The prior probability of A. In a screening example, this is the base rate before the test result. In a spam example, it is the starting chance that a message is spam.
P(B|A)
The probability of seeing B when A is true. In a test example, it is how often a person with the condition gets a positive result.
P(B|¬A)
The probability of seeing B even when A is false. This is the false-positive side of the problem and often changes the final result a lot.
The calculator builds P(B) first, then divides the A share
P(A|B) is the posterior probability: the probability of A after B is known. The calculator first finds how often B appears overall, then divides the part that came from A by that total.
A positive result can still give a modest posterior when the base rate is low
Suppose A means “the condition is present” and B means “the test is positive.” With P(A)=0.01, P(B|A)=0.9, and P(B|¬A)=0.05, the calculator returns P(B)=0.058500, P(A|B)=0.153846, and P(¬A|B)=0.846154.
The medical example is only a probability-reading example
These numbers show how the base rate and the false-positive rate affect Bayes’ theorem. Real test interpretation, diagnosis, or treatment decisions depend on the test, the person, and professional guidance.
Do not treat P(B|A) and P(A|B) as the same statement
The most common mistake is reversing the condition. “B when A is true” and “A after B is observed” point in different directions, and the prior probability P(A) can make the answers very different.
- Convert percentages to decimals. Use 0.05 for 5% and 0.95 for 95%.
- Do not ignore false positives. If P(B|¬A) is not zero, B can appear even when A is false.
- Check impossible evidence. When P(B) is 0, the posterior cannot be meaningfully interpreted.
- Keep the model binary. This calculator splits the world into A and not A; problems with many causes need a simplified setup.
Frequently asked questions
Where should P(A) come from?
P(A) is the base probability before the evidence is observed. Use observed data when you have it; otherwise compare several plausible scenarios instead of pretending one guess is certain.
Why are P(B|A) and P(A|B) different?
P(B|A) asks how often B appears if A is true. P(A|B) asks how plausible A is after B appears. The prior P(A) connects the two directions.
What is the sample button for?
Use the sample button to check the input format and the reading order of the result cards. Replace the sample values with probabilities that match your own problem.
Can the screening example be used for diagnosis?
No. It is an educational probability example. Real medical decisions require the actual test specification and professional interpretation.
Is a very small result always an error?
No. A low prior probability or a relatively high false-positive rate can make P(A|B) small. Only the P(B)=0 case means the input combination needs to be checked again.