Interview Q&A / Data Science

IntermediateQuick answer1 min readUpdated 3 Oct 2026

How does Bayes theorem work? Explain with a medical test example.

SHORT ANSWER

Bayes theorem updates a probability using new evidence: P(A|B) = P(B|A) x P(A) / P(B). It shows that a positive result from an accurate test can still mean a low chance of disease when the disease is rare.

Explain it simply

A test says "positive". What you want is the chance you are actually ill, but what the lab quotes is the chance of a positive when you are ill. These are different, and the gap depends on how common the disease is (the prior).

Easiest way to compute: use counts, not formulas.

Example

A disease affects 1% of people. A test catches 90% of sick people (sensitivity) and wrongly flags 5% of healthy people (false positive rate). Take 10,000 people:

  • Sick: 100, of whom 90 test positive
  • Healthy: 9,900, of whom 5% = 495 test positive
  • All positives: 90 + 495 = 585

P(sick | positive) = 90 / 585 = 0.154, about 15%.

python
sick, healthy = 100, 9900
tp = sick * 0.90
fp = healthy * 0.05
print(round(tp / (tp + fp), 3))  # 0.154

Even with a good test, about 85% of positives are false alarms, because healthy people vastly outnumber sick ones.

What to say in the interview

"Bayes theorem reverses a conditional probability: P(A given B) equals P(B given A) times the prior P(A), divided by P(B). The base rate matters. I usually work with natural frequencies, like 10,000 people, to avoid the base-rate fallacy. The same idea underlies spam filters and Naive Bayes classifiers."

Common mistakes

  • Treating P(positive | sick) as if it were P(sick | positive).

#bayes#conditional-probability#probability

Related questions

Practise more Data Science questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Data Science quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.