In this article
The formula and its parts
What is Bayes' theorem, and what does each term mean?
Bayes' theorem is the rule that updates the probability of a claim after you see evidence: P(A given B) equals P(B given A) times P(A), divided by P(B). The first factor is the likelihood, the chance of the evidence if the claim is true. P(A) is the prior, what you believed before the evidence. The result is the posterior, your belief after it. P(B) rescales so the posterior probabilities add to one.
Why it is asked: it checks that you can name every term, not only recite the formula.
Where does Bayes' theorem come from?
It follows from writing the probability of both A and B two ways. P(A and B) equals P(A given B) times P(B), and also equals P(B given A) times P(A). Set the two equal and divide by P(B). The rule is named for the Reverend Thomas Bayes; his essay was read to the Royal Society on 23 December 1763 after Richard Price found it among his papers (Bayes and Price, 1763). Bayes posed the problem of judging an unknown event's chance from how often it has happened and failed.
Why it is asked: a two-line derivation shows you do not treat the formula as magic.
What is the difference between P(A given B) and P(B given A)?
They answer different questions and are usually different numbers. P(positive given sick) is how often the test catches the disease. P(sick given positive) is how likely a person with a positive result is to be sick. Swapping the two is a classic error, known as confusion of the inverse, and Bayes' theorem is the bridge between them, with the prior as the missing ingredient.
Why it is asked: confusing the two, sometimes called the prosecutor's fallacy, is the failure these questions are built to catch.
What are a prior, a likelihood and a posterior in plain words?
The prior is what you believed before looking at the data, the likelihood is how well each possible claim explains the data you saw, and the posterior is the updated belief that combines them. Think of a bet: you start with odds, the evidence multiplies them, and the result is your new odds. In an interview, give one concrete example of each rather than only the definitions.
Why it is asked: it tests whether you can use the vocabulary on a real case.
Read next: the probability and statistics overview lists the neighbouring topics, and the page on maximum likelihood versus maximum a posteriori shows the same prior at work in estimation.
Classic worked problems
A test is 99% sensitive with a 5% false-positive rate, and 1% of people are sick. Someone tests positive. What is the chance they are sick?
About 16.7%, or 1 in 61. Here sensitivity is the share of sick people the test catches, the false-positive rate is the share of healthy people it wrongly flags, and prevalence is the share of people who have the condition. Use counts of people instead of probabilities, called natural frequencies. Of 10,000 people, 100 are sick and 99 of them test positive. Of the 9,900 healthy, 5% or 495 also test positive. So 99 of 594 positives are sick. The values are illustrative, chosen to show the effect, not taken from a real test.
Why it is asked: it is the standard base-rate question, and a common wrong answer is the test's own 99%.
Text description of the diagram
- Of 10,000 people, 100 are sick and 9,900 are healthy.
- There are 99 true positives and 495 false positives, so 99 of 594 positive tests are real.
Gigerenzer and Hoffrage found that people reason better with counts like these. In their analysis of several thousand solutions, participants given frequency formats reached up to 50% of their inferences with Bayesian algorithms (Gigerenzer and Hoffrage, 1995).
Why does the answer change when the condition is rarer or more common?
Because the prior sets how many positives are false alarms. With the same test, the chance of disease given a positive is 1.9% at a prevalence of 0.1%, 16.7% at 1%, 68.8% at 10% and 95.2% at 50%1. When the condition is rare, healthy people vastly outnumber sick ones, so a false-positive rate that is large next to the prevalence, such as 5% against 1%, gives more false alarms than true cases. The exact rule: posterior odds fall below 1 when prior odds are below the false-positive rate divided by the sensitivity. A very reliable test escapes this: at 0.1% prevalence, 99% sensitivity and a 0.001% false-positive rate, a positive means 99% sick1.
Why it is asked: it shows you understand the answer is not a property of the test alone.
Text description of the diagram
- At a prevalence of 0.1 percent the chance of disease after a positive is 1.9%.
- At a prevalence of 50 percent the chance of disease after a positive is 95.2%.
What if the same person tests positive a second time?
Treat the first posterior as the new prior. Starting from 16.7%, a second independent positive result lifts the chance to 79.8%1. The word independent matters: this assumes the two tests err independently given the person's true state. If both fail for the same reason, such as a shared interfering substance, the second result adds far less than the arithmetic says.
Why it is asked: it tests sequential updating and whether you state the independence assumption.
Can you do Bayes' theorem with odds instead of probabilities?
Yes, and it is often faster. Posterior odds equal prior odds times the likelihood ratio, where the likelihood ratio is the chance of the evidence if sick divided by the chance if healthy. Here the prior odds are 0.0101 and the likelihood ratio is 0.99 divided by 0.05, which is 19.8, so the posterior odds are 0.2, a probability of 16.7%1. Each independent piece of evidence multiplies the odds again.
Why it is asked: odds form lets you update in your head and combine several clues.
In the Monty Hall problem, should you switch doors?
Yes. Staying wins one time in three and switching wins two in three, because your first pick was right only a third of the time and the host's reveal moves that remaining two-thirds onto one door. In a simulation of 100,000 games with a fixed seed, where the host always opened a goat door that was not your pick, staying won 33.2% and switching won 66.8%1. The host knowing where the car is and never opening it is what makes switching win two in three; a host who opens a door at random and happens to show a goat leaves the other two doors at one in two.
Why it is asked: it tests whether you condition on how the evidence was produced.
Knowing it is half the job. Saying it is the other half.
Interview Clozo is an AI interview copilot for real interview rounds: it hears the question and puts a strong answer on your screen, and you say it in your own words. See the features or how it works.
Start Free Trial →Bayesian inference and priors
What is a conjugate prior, and what does the Beta-Binomial update look like?
A conjugate prior is a prior that, combined with a given likelihood, returns a posterior of the same family, so the update is just arithmetic. A Beta(a, b) distribution describes an unknown probability between 0 and 1; a and b act like prior counts of heads and tails. For coin flips, a Beta(a, b) prior with k heads in n flips gives a Beta(a plus k, b plus n minus k) posterior. With a Beta(2, 2) prior and 7 heads in 10 flips, the posterior is Beta(9, 5), with a mean of 0.643 and a 95% credible interval of 0.386 to 0.8611.
Why it is asked: it is the smallest complete Bayesian model and a common whiteboard task.
How do maximum likelihood, MAP and the full posterior differ?
Maximum likelihood estimation (MLE) picks the parameter that makes the data most likely and ignores any prior; here it gives 0.7. Maximum a posteriori (MAP) estimation picks the peak of the posterior, which with the Beta(2, 2) prior is 0.667, and the full posterior keeps the whole distribution. With a flat Beta(1, 1) prior the MAP equals the MLE at 0.71. The page on MLE versus MAP goes further.
Why it is asked: it tests whether you see MAP as MLE plus a prior.
What does a prior do when you have a lot of data?
It washes out. With the same Beta(2, 2) prior and 70 heads in 100 flips, the posterior mean is 0.692, close to the data's 0.7, and the 95% credible interval narrows to 0.601 to 0.7771. With 10 flips the prior pulled the mean down to 0.643. The more data you have, the less the prior matters, and a strong, wrong prior needs much more data to overcome.
Why it is asked: it separates the intuition that priors are arbitrary from the fact that data dominates.
What is the difference between a credible interval and a confidence interval?
A credible interval is a range that, given the model and prior, holds the parameter with the stated probability: a 95% credible interval means a 95% probability the parameter lies inside. A confidence interval makes a statement about the procedure: across repeated samples, 95% of such intervals would contain the true value. For a single interval, the credible reading is the one people usually want. The confidence side is the one taught alongside the t-test. Read the full explanation on the t-test page.
Why it is asked: it checks that you can state the two meanings without mixing them.
Probability puzzles interviewers ask
These are classic puzzles in the style of quantitative and statistics rounds. Each one is the same table method: list the cases, weight each by its prior, keep only the cases that fit what you saw, and divide.
A jar has 1,000 coins, one double-headed. You pick one at random and flip 10 heads in a row. What is the chance it is the double-headed coin?
1024 in 2023, about 0.5061. The double-headed coin gives 10 heads with certainty, so its weight is 1 in 1,000 times 1. A fair coin gives 10 heads with probability 1 in 1,024, so the 999 fair coins together weigh 999 in 1,024,000. Dividing gives 1024 over 1024 plus 999. Ten heads turn a one-in-a-thousand suspicion into a coin flip.
Why it is asked: it is the cleanest prior-versus-likelihood trade.
Coin A lands heads with probability 2/3 and coin B with probability 1/3. A coin is chosen at random and flipped three times, all heads. What is the chance it is coin A?
8 in 9, about 0.8891. Three heads have probability 8/27 for coin A, since (2/3) cubed is 8/27, and 1/27 for coin B. The priors are equal, so they cancel and the answer is 8 over 8 plus 1. The coin that lands heads more often is simply 8 times as likely to have produced the run.
Why it is asked: equal priors reduce it to a likelihood ratio, which tests whether you notice that.
Three coins: one heads on both sides, one tails on both, one fair. You pick one, toss it, and see heads. What is the chance it is the two-headed coin?
2 in 31. Count the faces you could be looking at: the two-headed coin has two heads faces, the fair coin one, the tails coin none. Two of the three heads faces belong to the two-headed coin. The tempting answer of 1 in 2 treats the two-headed and fair coins as equally likely, but the two-headed coin has twice as many ways to show heads.
Why it is asked: the tempting answer is 1 in 2, and the question checks that you condition on the evidence.
James goes to the gym every Monday and Tuesday, and on each other day independently with probability 30%. He is spotted at the gym on a random day. What is the chance it is Monday?
2 in 7, about 0.2861. Weight each day by its chance of a gym visit: Monday 1, Tuesday 1, and the five other days 0.3 each, 1.5 in total. Monday is 1 out of 3.5, which is 2 in 7. Without the weights you would say 1 in 7, which ignores that Monday and Tuesday are certain gym days.
Why it is asked: it tests whether you weight the days by likelihood rather than treating them as equally likely.
Three bowls hold two blue balls, two red balls, and one red and one blue. You draw a blue ball from a random bowl. What is the chance the next ball from the same bowl is also blue?
2 in 31. The blue ball came from the blue-blue bowl with weight 1 in 3 or from the mixed bowl with weight 1 in 6. The next ball is blue only in the first case, so the answer is (1/3) over (1/3 plus 1/6).
Why it is asked: it is the three-coins puzzle in disguise, and interviewers watch for whether you see that.
A 3x3x3 cube is painted on the outside and cut into 27 unit cubes. You pick one at random and the face toward you is painted. What is the chance it is a corner cube?
4 in 9, about 0.4441. Count painted faces: 8 corner cubes show 3 each, 12 edge cubes 2 each, 6 face-centre cubes 1 each, and the middle cube none. That is 24 plus 24 plus 6 painted faces, and 24 of the 54 belong to corners.
Why it is asked: the face you see is the evidence, so each cube is weighted by how many painted faces it has.
A disease affects 1% of people and a test is 95% accurate. Someone tests positive. What is the chance they have it?
About 16%, if "95% accurate" means 95% sensitivity and 95% specificity (specificity is the share of healthy people the test correctly clears): 0.1611. The wording is ambiguous, and saying so aloud shows you read the question. State your reading, then count: of 10,000 people, 95 of the 100 sick test positive, and 495 of the 9,900 healthy do.
Why it is asked: it is the base-rate question in a familiar phrasing, and the vague word "accurate" tests whether you state your reading before you calculate.
Naive Bayes in machine learning
What is naive about naive Bayes?
It assumes the features are conditionally independent given the class. The scikit-learn documentation writes the assumption as P(x_i given y and all other features) equal to P(x_i given y), which turns a hard joint probability into a product of simple ones (scikit-learn 1.9.1 documentation). The assumption is rarely true, since words in an email are correlated, yet the classifier is often good enough.
Why it is asked: it tests whether you know what the method assumes, not only what it outputs.
Why does naive Bayes need smoothing?
A word that never appeared in a class gives a likelihood of zero, which wipes out every other piece of evidence in the product. Take 100 emails, 60 spam and 40 not, where "free" appears in 30 spam and no non-spam: the raw posterior for spam is 1.0, certain. Adding one to every count, called Laplace smoothing, gives 0.9691. The scikit-learn page describes the smoothing prior alpha, and says that setting it to 1 is Laplace smoothing (scikit-learn 1.9.1 documentation).
Why it is asked: it is the standard practical failure of the method.
Why do implementations add log probabilities instead of multiplying?
Multiplying many small probabilities underflows to zero. With 200 words, each with a likelihood of 0.001, the plain product in 64-bit floating point is exactly 0.0, while the sum of the natural logarithms is about minus 1,381.55 and still comparable between classes1. Since the logarithm preserves order, picking the class with the largest log score gives the same decision.
Why it is asked: it tests whether you have ever implemented the method on real text.
Why can naive Bayes classify well and still give poor probabilities?
Because the independence assumption double-counts correlated evidence, which pushes probabilities toward 0 and 1 often without changing which class wins. In a toy case with a spam prior of 0.6 and a likelihood ratio of 5, one copy of a word gives a posterior of 0.882, but treating two perfect duplicates as independent gives 0.9741. The scikit-learn 1.9.1 documentation says naive Bayes is a decent classifier but a bad estimator, so predict_proba should not be taken too seriously.
Why it is asked: it separates ranking well from being calibrated.
Bayes in machine learning systems
Where does Bayes appear in your ML system?
Three places are easy to defend. A classifier's output used with a base rate: a fraud score is only useful after you account for how rare fraud is. Naive Bayes and its relatives for text, covered above. And any model that updates a belief with new data, such as the Beta-Binomial update above for a click rate. Pick one system you built and say what the prior was, even if you never wrote it down. Read the full explanation of the classical models in classical machine learning.
Why it is asked: it is a follow-up the interviewer uses to see whether you connect the theory to real work.
When would you pick naive Bayes over a larger model?
When data is small, features are many and sparse, training must be very fast, or you need a baseline. It fits by counting, so it trains in one pass, and the scikit-learn page says naive Bayes learners and classifiers can be extremely fast compared to more sophisticated methods (scikit-learn 1.9.1 documentation). Say the cost too: with plenty of data you should test a richer model against it on your own metric rather than assume either wins.
Why it is asked: it tests judgment about trade-offs, not only the method.
Explaining Bayes in the interview
How do you explain Bayes' theorem to a non-technical interviewer?
Use counts and a story: "Imagine 10,000 people. A hundred are sick; the test catches 99 of them. Of the 9,900 healthy people it wrongly flags 495. So of 594 positives, only 99 are sick." That takes one breath and needs no formula. Then name the lesson, that how common something is before the test matters as much as how accurate the test is. Read the full explanation of how to shape the answer in the answer-structure guide.
Why it is asked: interviewers use it to test clear communication as much as maths.
How to practise
Work three problems from scratch each day for a week: one medical test, one with odds, and one Beta-Binomial update. Say each answer aloud in under a minute, starting with the counts. Then widen out to the machine learning classics and the normal distribution page, which covers a shape many continuous priors and likelihoods take. Keep a short list of the numbers above: 16.7% for the base problem, 0.2 for the posterior odds, two in three for Monty Hall. For another classic trap in reading evidence, see correlation versus causation.
- Bayes' theorem converts P(evidence given claim) into P(claim given evidence) using a prior.
- Count people, not percentages: 99 of 594 positives are real in the base problem.
- When a condition is much rarer than the test's false-positive rate, most positives are false alarms, however sensitive the test.
- Posterior odds equal prior odds times the likelihood ratio.
- Naive Bayes multiplies per-feature likelihoods, needs smoothing, and is better at ranking than at probability.
Sources
- An Essay towards solving a Problem in the Doctrine of Chances, Philosophical Transactions 53 (Bayes, communicated by Price) — Royal Society (transcription hosted by Georgia Tech), 23 Dec 1763
- How to improve Bayesian reasoning without instruction: frequency formats, Psychological Review 102(4), 684-704 — American Psychological Association (Gigerenzer and Hoffrage; record at the University of Lausanne), 1 Oct 1995
- 1.9. Naive Bayes, scikit-learn 1.9.1 documentation — scikit-learn developers (page copyright 2007-2026, read 2026-10-24), 24 Oct 2026
- Bayesian Data Analysis, third edition: book page with the free PDF — Gelman, Carlin, Stern, Dunson, Vehtari and Rubin (author page, read 2026-10-24), 24 Oct 2026