datarekha

Bayes' Theorem

Flip a conditional probability around: from P(evidence given cause) to P(cause given evidence). The single most-tested idea in GATE DA probability.

9 min read Intermediate GATE DA Lesson 7 of 122

What you'll learn

  • Bayes' theorem as the inversion of a conditional: from P(E|H) to P(H|E)
  • Prior, likelihood, evidence (normaliser), and posterior — what each term is
  • Working a medical-test problem to a numeric answer (a real 2026 question)
  • Why base rates make a positive test on a rare condition usually a false alarm

Before you start

You believe something. New evidence shows up. You update. That’s the whole story — Bayes’ theorem is just the precise arithmetic for that update.

It matters because the number you can measure (the test’s accuracy: P(positive | disease)) is almost never the number you want (the answer to “do I have it, given I tested positive?”: P(disease | positive)). Bayes is the rule that flips the conditional around so the numbers come out right — and it’s the single most-tested idea in GATE DA probability.

The formula

P(H | E)=P(E | H) · P(H)P(E)posteriorlikelihoodpriorevidence (normaliser)
Posterior belief = how well the cause explains the evidence, scaled by how likely the cause was to begin with.
  • Prior P(H) — belief in the hypothesis before the evidence.
  • Likelihood P(E | H) — how probable the evidence is if the hypothesis holds.
  • Evidence P(E) — total probability of the evidence (the total-probability denominator from the last lesson; it just makes the answer sum to 1).
  • Posterior P(H | E) — updated belief after seeing the evidence.

Build the intuition with a coin of unknown bias: the prior (dashed) reshapes into a posterior (bold) as each flip arrives.

Worked example — a real 2026 question

A disease affects 30% of a population. A test detects it correctly 80% of the time (sensitivity), but also gives a 10% false-positive rate on healthy people. A person tests positive. What is the probability they have the disease?

Lay out the pieces, then apply the formula with total probability in the denominator:

P(D) = 0.30,  P(+|D) = 0.80,  P(+|¬D) = 0.10,  P(¬D) = 0.70

P(D | +) =        P(+|D)·P(D)
            ─────────────────────────────
            P(+|D)·P(D) + P(+|¬D)·P(¬D)

         =       0.80 · 0.30
            ──────────────────────────  =  0.24 / 0.31  ≈  0.77
            0.80·0.30 + 0.10·0.70

So ≈ 0.77. (This is GATE DA 2026, Q57 — answer 0.77.) The disease was common enough (30%) that a positive test is convincing.

Now contrast with a rare disease — drag the prior down here and watch the posterior collapse:

How GATE asks this

Almost always a NAT: a 2-to-4-hypothesis setup (boxes, machines, disease, spam) where you must compute one posterior to 2 decimals. The recipe never changes: write the priors and likelihoods, build the evidence denominator by total probability, divide. GATE DA 2025’s Q31 used three boxes with unequal priors (½, ⅙, ⅓) and asked P(Box 2 | white ball) — the answer was 0.25, found by exactly this procedure with three terms in the denominator.

Quick check

Quick check

0/5
Q1A disease has 1% prevalence. A test is 99% sensitive (P(+|disease)=0.99) with a 5% false-positive rate. A person tests positive. P(disease | positive)? (2 decimals)numerical answer — type a number
Q2Recall the factory: Machine 1 makes 60% at 2% defect, Machine 2 makes 40% at 5% defect. Given an item is defective, P(it came from Machine 2)? (3 decimals)numerical answer — type a number
Q3A test is 90% accurate at detecting a condition. Someone reasons: 'I tested positive, so there's a 90% chance I have it.' What's wrong?
Q4Which statements about Bayes' theorem are TRUE? (select all that apply)select all that apply
Q5A spam filter: 40% of incoming email is spam. The word 'free' appears in 60% of spam but only 5% of legitimate email. An email contains 'free'. P(spam | 'free')? (2 decimals)numerical answer — type a number

Practice this in an interview

All questions

Sign in to track your progress

Completed lessons, your XP, level, and streak save to your account — it's free and takes a few seconds.

Explore further

Related lessons

Skip to content