Updating a probability with new information

Conditional probability answers the question: how likely is A once I know B has occurred? Knowing B narrows the possibilities to the cases where B is true, and A is then judged within that smaller set. This page takes two inputs, the probability that both A and B occur and the probability of B, and returns the probability of A given B. It applies to medical tests, quality checks, card draws, weather and any situation where one fact changes the odds of another. It is also the basis of Bayesian reasoning, where beliefs are updated as evidence arrives.

The definition

The formula is P(A | B) = P(A and B) / P(B). The numerator is the share of all outcomes where both events occur, and the denominator is the share where B occurs. Dividing gives the fraction of B outcomes that are also A outcomes. The conditioning probability P(B) must be greater than zero, because you cannot condition on an impossible event. The joint probability cannot exceed P(B), since the cases with both A and B are a subset of the cases with B. Independence is not assumed, and the answer differs from P(A) exactly when the events are related.

Dividing a joint 0.12 by a marginal 0.3

The page starts with P(A and B) = 0.12 and P(B) = 0.3. Dividing gives 0.4. Among the outcomes where B holds, 40 percent also have A. If you also know P(A) is 0.5, you can see that learning B lowered the probability of A from 0.5 to 0.4, so the events are not independent. If P(A) had been 0.4, the events would be independent, because conditioning would not change anything. Comparing P(A | B) with P(A) is the quickest test for independence. The same numbers also give the reverse conditional if you know P(A): with P(A) = 0.5, P(B | A) = 0.12 / 0.5 = 0.24, a different number from 0.4 even though both come from the same joint probability. A two-way table makes the contrast clear, because one conditional divides by a column total and the other by a row total.

A screening test

Consider a condition with 1 percent prevalence and a test that is positive for 95 percent of people who have it and 5 percent of people who do not. These numbers are illustrative. The probability of a positive result and the condition is 0.01 × 0.95 = 0.0095. The probability of any positive is 0.0095 + 0.99 × 0.05 = 0.059. So the probability of having the condition given a positive result is 0.0095 / 0.059, about 0.161. Most positive results come from the larger group without the condition, which surprises many people. The result depends heavily on prevalence. If the same test were given to a group where 20 percent have the condition, the joint probability would be 0.2 × 0.95 = 0.19, the chance of any positive would be 0.19 + 0.8 × 0.05 = 0.23, and the page would give 0.19 / 0.23, about 0.826. The test did not change, yet a positive result now carries much more weight. This is why screening programs target groups with higher risk, and why a single test result should be read together with the background rate.

Cards without replacement

The chance that the second card is an ace given that the first was an ace is 3/51, about 0.0588. You can obtain it from the page: the chance of two aces in a row is 4/52 × 3/51, about 0.004525, and the chance of the first card being an ace is 4/52, about 0.076923. Dividing gives 0.0588. That small drop from 4/52, about 0.0769, reflects that one ace is gone and the deck is smaller. The example shows how conditioning on earlier draws changes later probabilities without replacement.

Where to get the inputs

The joint probability may come from a table of counts, a Venn diagram or a two-way frequency table. Divide the count of outcomes with both A and B by the total number of outcomes. P(B) comes from the column or row total divided by the same total. If a problem gives you P(B | A) and P(A) instead, multiply them to obtain the joint probability first. The two inputs must come from the same population and the same scale, as probabilities between 0 and 1. If you have percentages, divide by 100, so 12 percent becomes 0.12.

Mixing up the two directions of conditioning

The most frequent error is confusing P(A | B) with P(B | A). They are different numbers: the chance that a person with a disease tests positive is not the chance that a person who tests positive has the disease. The second error is dividing by P(A) instead of P(B). The third is using the probability of A alone in place of the joint probability, which treats the events as if B were certain. Check by asking which group you are restricting to, and use that group's probability in the denominator.

Link to Bayes' theorem

Because P(A and B) can be written as P(B | A) × P(A), the formula leads to Bayes' theorem: P(A | B) = P(B | A) × P(A) / P(B). Use this page when you already have the joint probability, and use Bayes' theorem when you start from the reverse conditional. The two routes give identical answers when the inputs are consistent. The screening example above is a standard case, where the reverse conditional is the test sensitivity and the prior is the prevalence. The theorem carries the name of Thomas Bayes, whose work was published after his death in 1763. Pierre-Simon Laplace later developed and generalized it.

Consistency of the two supplied probabilities

The page divides two numbers you supply. It cannot check that they describe the same sample, are consistent with each other or are estimated from enough data. A joint probability larger than P(B) is inconsistent and produces a value above 1, which is not a valid probability. Small samples give unstable estimates. The result is only as good as the inputs and says nothing about causation, since A being likely given B does not mean B causes A. A well-known trap is the base rate fallacy, where a vivid conditional probability is read without the underlying frequency of the event, as in the screening example. Another is the prosecutor's fallacy, which treats the probability of evidence given innocence as the probability of innocence given evidence. Using the correct denominator avoids both.