This Website is not fully compatible with Internet Explorer.
For a more complete and secure browsing experience please consider using Microsoft Edge, Firefox, or Chrome

The Vampire Problem: An Analytical solution

3. The Vampire Problem: An Analytical solution

This section introduces a simple example of Bayesian reasoning: the vampire problem. The example is adapted from Richard McElreath's book Statistical Rethinking, which uses intuitive examples to explain probability, inference and statistical modelling.

The problem considers a fictional blood test for detecting whether someone is a vampire. Although the example is deliberately playful, the reasoning is directly relevant to engineering, diagnostics and reliability assessment. A test can appear accurate and still give misleading conclusions when the event being tested for is rare.

 

 

The information we are given

  • The probability that the test is positive if someone is a vampire is 90%: P(positive | vampire) = 0.90.
  • The probability that the test is positive if someone is mortal is 8%: P(positive | mortal) = 0.08.
  • The probability that a randomly selected person is a vampire is only 1%: P(vampire) = 0.01.

The question is: if someone receives a positive test result, what is the probability that they are actually a vampire?

It may be tempting to answer close to 90%, because the test correctly identifies vampires most of the time. However, that ignores the base rate. Vampires are rare, so most positive test results may still come from mortals who received a false positive result.

Using Bayes' theorem

Bayes' theorem allows us to calculate the probability of being a vampire given that the test result is positive:

P(vampire | positive) = P(positive | vampire)P(vampire) / P(positive)

The denominator, P(positive), is the overall probability of a positive test result. There are two ways to get a positive result:

  • the person is a vampire and the test correctly gives a positive result;
  • the person is mortal and the test incorrectly gives a positive result.

Using the marginalisation rule:

P(positive) = P(positive | vampire)P(vampire) + P(positive | mortal)P(mortal)

Substituting the values:

P(positive) = 0.90 × 0.01 + 0.08 × 0.99 = 0.0882

Therefore:

P(vampire | positive) = 0.90 × 0.01 / 0.0882 = 0.102

So, after a positive test result, the probability that the person is actually a vampire is only about 10.2%.

Why the result is so low

The result is low because the positive-test group contains both true positives and false positives. The true-positive contribution is:

0.90 × 0.01 = 0.009

The false-positive contribution is:

0.08 × 0.99 = 0.0792

Even though the false-positive rate is only 8%, mortals are so common that they dominate the positive-test population. This is why P(positive | vampire) is not the same as P(vampire | positive).

The engineering lesson is that test accuracy alone is not enough. When looking for a rare event, such as an uncommon defect or a rare failure mode, the base rate matters. A moderately reliable test may still produce many false alarms if the event being tested for is very uncommon.