Quick Summary: Bayes’ theorem — P(A|B) = P(B|A)·P(A)/P(B) — is the most-tested single formula in GATE DA. It appears directly in Probability & Statistics, powers naive Bayes in Machine Learning, and generalises into Bayesian networks in the AI section: one formula, three sections of the paper. This deep dive derives it from first principles, builds the base-rate intuition that examiners test, and works three complete PYQ-style problems step by step.
By Piyush Wairale — Instructor, BS Data Science program at IIT Madras · IIT Madras alumnus · 10,000+ GATE students mentored · Last updated: August 2026
Key Takeaways
- Bayes’ theorem inverts conditionals: P(A|B) = P(B|A)·P(A)/P(B) — it converts “probability of evidence given cause” into “probability of cause given evidence”.
- In every GATE problem, expand the denominator with the law of total probability: P(B) = P(B|A)·P(A) + P(B|Aᶜ)·P(Aᶜ).
- The base-rate effect: with a rare condition (say 1%), even a 95%-accurate test yields a posterior of only ~16% after one positive result — priors dominate weak evidence.
- When the question only asks which hypothesis is more likely, skip the denominator entirely — compare numerators P(B|Aᵢ)·P(Aᵢ) directly.
- Naive Bayes (ML section) is Bayes’ theorem with a feature-independence assumption; a Bayesian network (AI section) is Bayes’ theorem organised on a graph — mastering this one formula pays in three sections.
On this page
The 3-line derivation · Law of total probability · The base-rate intuition · Problem 1: disease test · Problem 2: factory defect · Problem 3: spam filter · Common mistakes · Naive Bayes & Bayesian networks · FAQs
If you learn one computation to full fluency before GATE DA, make it this one. Bayes’ theorem questions have appeared in essentially every GATE DA paper so far and in decades of GATE CS papers before that — always the same skeleton wearing different clothes: a cause you cannot observe, evidence you can, and a question that runs the arrow backwards. This deep dive complements our Probability & Statistics pillar guide with the thing pillars can’t fit: full worked solutions at exam depth. For lectures and a test series on the whole subject, see the Probability & Statistics for GATE DA Course.
Watch Free: Probability Lectures on YouTube
Bayes’ theorem and the full Probability & Statistics syllabus, taught with GATE-style numericals on Piyush Wairale’s channel:
Subscribe to Piyush Wairale IITM on YouTube for new GATE DA lectures, PYQ solutions and strategy sessions.
The Three-Line Derivation
Everything comes from the definition of conditional probability. For events A and B with P(B) > 0:
P(A|B) = P(A∩B)/P(B) and P(B|A) = P(A∩B)/P(A)
Both expressions contain the same joint probability P(A∩B). Solve each for it — P(A∩B) = P(A|B)·P(B) = P(B|A)·P(A) — and divide by P(B):
P(A|B) = P(B|A) · P(A) / P(B)
Name the pieces the way statisticians do, because GATE options sometimes use these words: P(A) is the prior (belief before evidence), P(B|A) is the likelihood (how expected the evidence is under the hypothesis), P(B) is the evidence (total probability of what you observed), and P(A|B) is the posterior (belief after evidence). The theorem is nothing more than a rule for updating beliefs in the light of data — which is why it sits at the heart of data science.
The Law of Total Probability: The Denominator Machine
In exam problems you are almost never given P(B) directly — you build it. If A₁, A₂, …, Ak partition the sample space (mutually exclusive, covering everything), then:
P(B) = Σᵢ P(B|Aᵢ)·P(Aᵢ) — for two hypotheses: P(B) = P(B|A)·P(A) + P(B|Aᶜ)·P(Aᶜ)
Read it as a weighted average: the evidence can arrive through any of the possible causes, each weighted by how probable that cause is. Every worked problem below uses exactly this expansion — it is the single mechanical habit that makes Bayes questions safe: write the partition, write the branch probabilities, sum the paths to the evidence. Drawing a quick two-level tree (causes on level one, evidence on level two) turns any of these problems into arithmetic.
The Base-Rate Intuition GATE Actually Tests
Here is the psychological trap the examiners exploit. A test is “95% accurate,” someone tests positive, and intuition screams “95% chance they have it.” Wrong — because intuition ignored the base rate. If only 1% of the population has the condition, then in a crowd of 10,000 people there are ~100 true cases (of whom ~95 test positive) and ~9,900 healthy people (of whom ~495 also test positive at a 5% false-positive rate). Among the ~590 positives, only 95 are real: about 16%. The false positives outnumber the true ones because the healthy group is a hundred times larger. That frequency picture — imagine 10,000 people and count — is the fastest sanity check in the exam hall, and questions are routinely designed so the intuitive-but-wrong answer sits among the options.
Worked Problem 1: The Diagnostic Test (Classic 2-Mark NAT)
Question. A disease affects 2% of a population. A test detects it with probability 0.9 when present, and falsely flags a healthy person with probability 0.08. A randomly selected person tests positive. Find the probability (rounded to two decimals) that the person actually has the disease.
Solution. Define D = has disease, + = tests positive. Given: P(D) = 0.02, P(+|D) = 0.9, P(+|Dᶜ) = 0.08, so P(Dᶜ) = 0.98.
Denominator first (total probability): P(+) = P(+|D)P(D) + P(+|Dᶜ)P(Dᶜ) = 0.9 × 0.02 + 0.08 × 0.98 = 0.018 + 0.0784 = 0.0964.
Then Bayes: P(D|+) = 0.018 / 0.0964 ≈ 0.19. Despite a “90% accurate” test, one positive result means only a 19% chance of disease — the base rate at work. Frequency check: in 10,000 people, 200 sick → 180 true positives; 9,800 healthy → 784 false positives; 180/(180+784) = 0.187 ✓.
Worked Problem 2: The Factory Defect (Multi-Hypothesis Form)
Question. A factory has three machines. M₁ produces 50% of output with a 1% defect rate; M₂ produces 30% with a 2% defect rate; M₃ produces 20% with a 4% defect rate. A randomly chosen item is defective. Which machine most likely produced it, and with what probability?
Solution. The partition is {M₁, M₂, M₃}. Numerators (path probabilities to “defective”): M₁: 0.50 × 0.01 = 0.005; M₂: 0.30 × 0.02 = 0.006; M₃: 0.20 × 0.04 = 0.008. Total: P(Def) = 0.005 + 0.006 + 0.008 = 0.019.
Posteriors: P(M₁|Def) = 0.005/0.019 ≈ 0.263; P(M₂|Def) = 0.006/0.019 ≈ 0.316; P(M₃|Def) = 0.008/0.019 ≈ 0.421. The answer is M₃ with probability ≈ 0.42 — the machine with the smallest share of production but the highest defect rate. Notice two exam habits: the three numerators alone were enough to rank the machines (skip the division when only the ranking is asked), and the posteriors sum to 1 (a free arithmetic check).
Worked Problem 3: The Spam Filter (Naive Bayes Bridge)
Question. 40% of incoming mail is spam. The word “offer” appears in 60% of spam and 8% of legitimate mail; the word “free” appears in 50% of spam and 10% of legitimate mail. Assuming the words occur independently given the class, what is the probability a mail containing both words is spam?
Solution. Let S = spam, E = mail contains both words. By conditional independence: P(E|S) = 0.6 × 0.5 = 0.30 and P(E|Sᶜ) = 0.08 × 0.10 = 0.008.
Total probability: P(E) = 0.30 × 0.40 + 0.008 × 0.60 = 0.12 + 0.0048 = 0.1248.
Bayes: P(S|E) = 0.12 / 0.1248 ≈ 0.962. Two weak-ish clues, multiplied under the independence assumption, produce 96% confidence — this is the naive Bayes classifier from the ML syllabus, executed by hand. When GATE frames a question with per-feature probabilities and a class prior, recognise it instantly as this template: multiply the feature likelihoods within each class, weight by the priors, normalise (or just compare) — done.
The Five Mistakes That Cost Marks
- Confusing P(A|B) with P(B|A): “probability of a positive test given disease” is not “probability of disease given a positive test” — the entire theorem exists because these differ.
- Forgetting the false-positive branch: the denominator needs both paths to the evidence; dropping P(B|Aᶜ)·P(Aᶜ) is the most common numerical error.
- Using 1 − P(+|D) as the false-positive rate: sensitivity and specificity are separate numbers; read the question’s wording twice.
- Normalising when you don’t need to: for “which is more likely” questions, comparing numerators is faster and avoids division errors.
- Ignoring the base rate: if your answer is close to the test’s accuracy for a rare condition, you have almost certainly made this error — run the 10,000-people frequency check.
One Formula, Three Sections of GATE DA
| Where it appears | What it looks like | Our guide |
|---|---|---|
| Probability & Statistics | Direct 2-mark NATs like the three problems above | P&S pillar guide |
| Machine Learning | Naive Bayes classification from a frequency table — Bayes plus feature independence | ML pillar guide |
| Artificial Intelligence | Bayesian networks — Bayes’ theorem organised on a DAG, queried by variable elimination or sampling | Reasoning under uncertainty guide |
This is why the topic deserves deep-dive treatment: an hour spent making these computations automatic upgrades your score in three places at once. It is the single highest-leverage hour in GATE DA preparation.
Master Probability the Structured Way
Bayes’ theorem and the complete Probability & Statistics syllabus — lectures, solved GATE PYQs, topic-wise tests and doubt support:
- Probability & Statistics for GATE DA Course & Test Series — by IIT Madras alumnus Piyush Wairale.
- Complete GATE DA 2027 Course — all 7 subjects, 250+ hours, 4,000+ questions and full-length AI mock tests.
FAQs on Bayes’ Theorem for GATE DA
How often does Bayes’ theorem appear in GATE DA?
In some form, essentially every year — as a direct probability NAT, inside a naive Bayes ML question, or within the AI section’s Bayesian network material. It is the most reliable question topic in the paper.
What is the fastest way to solve a Bayes problem in the exam?
Draw the two-level tree (hypotheses → evidence), multiply along each path to get the numerators, sum them for the denominator, divide. If only a ranking is asked, stop at the numerators. Sanity-check rare-condition answers with the 10,000-people frequency picture.
What are prior, likelihood and posterior?
Prior P(A): belief before seeing evidence. Likelihood P(B|A): how probable the observed evidence is under a hypothesis. Posterior P(A|B): updated belief after the evidence. Bayes’ theorem is the recipe that turns the first two into the third.
How is naive Bayes different from plain Bayes’ theorem?
Naive Bayes applies the theorem with multiple features and assumes they are conditionally independent given the class — so the likelihood becomes a product of per-feature probabilities, exactly as in the spam-filter problem above. See the ML pillar guide for its classifier role.
Where should I practise more problems like these?
GATE DA PYQs from 2024 onward plus GATE CS probability PYQs (the question style is identical), and the topic-wise sets in the P&S course & test series. Aim for ten timed problems under four minutes each.
Three templates — diagnostic test, multi-machine defect, independent-features filter — cover every Bayes question GATE DA has asked. Work each until the tree-draw-multiply-sum-divide rhythm is automatic, keep the base-rate check in your pocket, and this corner of the paper is banked. Continue with the full Probability & Statistics guide or jump to the complete syllabus roadmap.
Make Every Probability Mark Count
Bayes’ theorem to hypothesis testing — lectures, solved PYQs, sectional tests and mentorship by Piyush Wairale (IIT Madras).
Join the P&S Course & Test Series Get the Complete GATE DA CourseRecent Post

A* search and alpha-beta pruning for GATE DA 2027: full open/closed-list trace, admissible heuristics, minimax with pruning counted leaf by leaf, solved problems.

Taylor series and maxima-minima for GATE DA 2027: standard expansions, e^0.1 and cos(0.2) approximated, derivative tests and the Hessian rule worked with solved problems.

Normal forms for GATE DA 2027: functional dependencies, attribute closure worked, 1NF to BCNF with full decompositions, checklist table and solved GATE problems.

SQL and relational algebra for GATE DA 2027: σ, π and joins worked on sample tables, GROUP BY and nested queries evaluated row by row, plus solved GATE problems.

BFS and DFS for GATE DA 2027: graph traversals traced step by step with queue and stack states, shortest paths, Python code, complexity and solved GATE problems.

Sorting algorithms in Python for GATE DA 2027: bubble, insertion, selection, merge and quick sort traced step by step, binary search, complexity table and solved problems.
Learn Daily, Wherever You Are
Free lectures, exam updates, PYQ discussions, and job alerts — delivered through our YouTube channel and Telegram communities.


