letx=

Probability and statistics

Conditional probability

The probability of A once you know B has happened: the share of B's outcomes that are also in A.

P(A∣B)=P(A∩B)P(B)

Calculator

The live calculator needs JavaScript. The worked example below shows the same steps it would.

See it move

ABrectangle: all outcomes
  • P(A ∪ B) = 0.3 + 0.4 − 0.12 = 0.58: the overlap is counted twice, so subtract it once.
  • Neither A nor B: 0.42.

What the symbols mean

P(A∣B)
the probability of A given B, P(A∣B)
P(A∩B)
the probability of both A and B
P(B)
the probability of B (must be greater than 0)

When to use it

Use it whenever extra information narrows the possibilities: the chance a card is a king given it is a heart, the chance a customer buys again given they bought once, readings from two-way tables. P(A∣B) and P(B∣A) are usually different numbers; Bayes' theorem converts one into the other.

Worked example

40% of households in a town own a dog, and 12% own both a dog and a cat. What is the probability that a dog-owning household also owns a cat?

  1. Start from the formula.

    P(A∣B)=P(A∩B)P(B)
  2. Substitute P(A∩B) = 0.12, P(B) = 0.4 and work it out.

    P(A∣B)=0.120.4
    =0.3

Answer P(cat | dog) = 0.3

Why it works

Knowing B happened shrinks the sample space to B. The outcomes where A also happens are A∩B, so the new probability is their share of B.

Common mistakes

  • Dividing by P(A) instead of the probability of the condition, P(B).
  • Swapping the condition: P(positive test | ill) is not P(ill | positive test).
  • Using P(A)·P(B) for the numerator when A and B are not independent.