Maximum decimal places: 6; Nearest, ties away from zero
P(A and B)
0.009
P(A or B)
0.0991
P(B)
0.0981
P(A | not B)
0.001109
P(not A)
0.99
P(not B)
0.9019
P(neither A nor B)
0.9009
P(exactly one of A, B)
0.0901
Independent?
No
After seeing B, the probability of A moves from 1% to 9.17%. In natural frequencies: of 10,000 cases, about 90 have A and show B, while 891 show B without A. Of the 981 cases showing B, about 90 have A.
For two events A and B, the addition rule gives P(A or B) = P(A) + P(B) − P(A and B), the multiplication rule gives P(A and B) = P(A) × P(B | A), and conditional probability is P(A | B) = P(A and B) / P(B). Bayes' theorem mode runs the conditional the other way: from a prior P(A) and the two evidence rates P(B | A) and P(B | not A), it returns the updated probability P(A | B).
The Bayes default is a screening test for a condition with 1% prevalence, 90% sensitivity and a 9% false-positive rate. A positive result raises the probability from 1% to 9.17%, because in 10,000 people the 90 true positives are outnumbered by 891 false positives.
Enter probabilities from 0 to 1; fractions such as 1/6 are accepted. Two-events mode rejects combinations that cannot exist, such as a P(A and B) larger than P(A) or P(B).
How to calculate probability
When all outcomes are equally likely, P(event) = favorable outcomes ÷ total outcomes. An even number on a fair die has 3 favorable faces out of 6, so P = 3/6 = 0.5. Every probability lies between 0, impossible, and 1, certain; 0.25 means a 25% chance.
Two events combine through the addition, multiplication and conditional rules below. Bayes' theorem, P(A | B) = P(B | A) × P(A) ÷ P(B), turns a conditional probability around, for example from a test's accuracy to the meaning of a positive result.
Probability formulas for two events
Complement: P(not A) = 1 − P(A).
Addition rule: P(A or B) = P(A) + P(B) − P(A and B). The overlap is subtracted because adding the two counts it twice.
Multiplication rule: P(A and B) = P(A) × P(B | A), which becomes P(A) × P(B) for independent events.
Conditional probability: P(A | B) = P(A and B) ÷ P(B), defined only when P(B) > 0.
Roll two dice, with A a six on the first and B a six on the second. Both happen with probability 1/6 × 1/6 = 1/36, and at least one six with 1/6 + 1/6 − 1/36 = 11/36, about 0.306.
With independent probabilities 0.5 and 0.4, both events happen with probability 0.2 and at least one with 0.7. Neither happens with 0.3, and exactly one with 0.5.
Relationship
P(A)
P(B)
P(A and B)
P(A or B)
P(A given B)
Independent
0.5
0.4
0.2
0.7
0.5
Mutually exclusive
0.3
0.45
0
0.75
0
Known intersection
0.6
0.5
0.4
0.7
0.8
Known conditional
0.6
0.5
0.3
0.8
0.6
In the last row the known input is P(B | A) = 0.5, so the multiplication rule gives P(A and B) = 0.6 × 0.5 = 0.3.
Independent vs mutually exclusive events
Independent events don't change each other's chances, so P(A and B) = P(A) × P(B): two coin flips, or two dice. Mutually exclusive events can't happen together, so P(A and B) = 0: heads and tails on the same flip.
Two events with positive probabilities can't be both. If A rules out B, learning that A happened drops B's chance to 0, the opposite of independence.
Conditional probability has a direction
P(A | B) and P(B | A) are usually different. In the known-intersection row, P(A | B) = 0.4 ÷ 0.5 = 0.8, but P(B | A) = 0.4 ÷ 0.6 = 0.667.
An overlap also has limits. It can't exceed either probability, and it must be at least P(A) + P(B) − 1. With 0.6 and 0.5 it lies between 0.1 and 0.5, so a stated P(A and B) of 0.7 is impossible.
Bayes' theorem with a worked example
Bayes' theorem updates a prior probability with evidence. Its denominator is the total chance of the evidence: P(B) = P(B | A) P(A) + P(B | not A) P(not A).
Take a condition affecting 1% of people, a test that detects 90% of cases and a 9% false-positive rate, the screening example used by Gigerenzer and colleagues (2007). Out of 10,000 people:
100 have the condition, and 90 of them test positive.
9,900 don't, and 891 of them test positive anyway.
Of the 981 positives, 90 are true: 90 ÷ 981 = 10/109, or 9.17%.
The 90% detection rate is not the chance that a positive result is right, because the large group without the condition supplies most of the positives.
Prior P(A)
P(B given A)
P(B given not A)
P(B)
Updated P(A given B)
0.01
0.9
0.09
0.0981
0.0917431193
0.1
0.9
0.09
0.171
0.5263157895
0.5
0.8
0.2
0.5
0.8
0
0.9
0.09
0.09
0
At a 10% prior, the same test's positive result means a 52.6% chance, so the answer depends on prevalence as much as on accuracy. A prior of 0 stays 0 whatever the evidence. If the evidence can never occur, P(B) = 0 and the update is undefined.
Common mistakes
Typing percentages as whole numbers. Probabilities run from 0 to 1, so 25% is 0.25. Fractions such as 1/6 also work.
Adding chances for "at least one". Four rolls of a die don't give 4/6 for at least one six. Use the complement: 1 − (5/6)⁴ = 671/1296, about 0.518.
Assuming independence. Draw two cards without replacement and, after a first ace, the second is an ace with probability 3/51, not 4/52.
Swapping the condition. A 90% chance of a positive test given the condition is not a 90% chance of the condition given a positive test; above it was 9.17%.
Forgetting the overlap. P(A) + P(B) alone is correct only for mutually exclusive events.
Checked against: Gigerenzer et al. (2007) mammography example (about 1 in 10 positives has the disease); exact 0.009/0.0981 = 10/109 with exact fractions
Checked against: Definition: P(A ∩ B) = 0; union is the plain sum
Known joint probability
Calculate
Two events
P(A)
0.6
P(B)
0.5
How A and B relate
I know P(A and B)
P(A and B)
0.4
P(A or B)
0.7
P(A | B)
0.8
P(B | A)
0.666667
P(neither A nor B)
0.3
P(exactly one of A, B)
0.3
Independent?
No
Checked against: Hand calculation with exact fractions: 0.4/0.5, 0.4/0.6 = 2/3, 1 − 0.7
Questions
How do you calculate the probability of A or B?
Add the two probabilities and subtract the overlap: P(A or B) = P(A) + P(B) − P(A and B). For independent events with P(A) = 0.5 and P(B) = 0.4, the overlap is 0.5 × 0.4 = 0.2, so P(A or B) = 0.7. For mutually exclusive events the overlap is 0, so the probabilities simply add: 0.3 + 0.45 = 0.75.
What is the difference between independent and mutually exclusive events?
Independent events don't affect each other's chances, so P(A and B) = P(A) × P(B). Mutually exclusive events can't happen together, so P(A and B) = 0. Two events with non-zero probabilities can't be both: if A rules out B, knowing A happened changes the chance of B to 0. Two coin flips are independent; heads and tails on one flip are mutually exclusive.
Why does a positive result on an accurate test often mean you probably don't have the condition?
Because false positives from the large healthy group can outnumber true positives from the small affected group. With 1% prevalence, 90% sensitivity and 9% false positives, only 9.17% of positives are true. At 10% prevalence the same test gives 0.09 / (0.09 + 0.081) = 52.6%. This probability is the test's positive predictive value, and it depends on prevalence as much as on accuracy.
How do you calculate the probability of at least one event happening?
Subtract the chance that it never happens from 1: P(at least one) = 1 − (1 − p)ⁿ for n independent tries with probability p each. The chance of at least one six in 4 rolls of a die is 1 − (5/6)⁴ = 671/1296, about 0.5177, just above even odds. With p = 0.01 you need 69 tries before the chance passes 50%.
Gigerenzer et al. (2007). Helping doctors and patients make sense of health statistics. Psychological Science in the Public Interest 8(2), 53–96
Checked against references
This calculator includes 6 worked examples with independently sourced answers. They run in the test suite, and you can run them here too.
Put this calculator on your site
Paste this where you want the calculator to appear. It is free to use, it stays in step with corrections made here, and the credit line below it links back so your readers can find the full version.