Your bank's AI just flagged a transaction. How worried should you be?
Your phone buzzes. "Suspicious activity detected: ₹40,000 debited from your account. Was this you?" A fraud-detection model running quietly in the background flagged the transaction in real time. Before you panic, ask yourself a sharper question: given that the AI flagged this transaction, what is the actual probability that it is fraud?
Most people answer instinctively: "the model is probably 90% accurate, so there's a 90% chance it's fraud." That instinct is almost always wrong, and it is wrong in a specific, mathematically precise way that costs banks, hospitals, and search engines real money and real trust every day. By the end of this chapter you will be able to compute the correct answer exactly — and you will see that it can be dramatically lower than 90%, even when the AI is doing its job well. The tool that gets you there is Bayes' theorem, and it is arguably the single most important piece of mathematics behind how modern AI systems — spam filters, medical-imaging classifiers, recommendation engines, fraud detectors, even large language models estimating "what word comes next" — represent and update belief in the face of incomplete information.
Refresher: sample spaces, events, and the three rules probability must obey
You already know the basics from Class 10: a random experiment has a sample space S, the set of every possible outcome. An event A is any subset of S. A probability function P assigns each event a number satisfying three axioms — P(A) ≥ 0 for every event, P(S) = 1, and for mutually exclusive events A and B, P(A ∪ B) = P(A) + P(B). Everything in this chapter, including Bayes' theorem, is built entirely out of these three rules. There is no new "law of nature" being introduced — only a new way of combining what you already know.
What Class 10 probability usually stops short of is this: what happens to P(A) once you learn that some other event B has definitely occurred? That is the question a fraud-detection AI is answering thousands of times a second, and it is the question this chapter answers rigorously.
Conditional probability: updating belief when new information arrives
Suppose a bank studies 10,000 UPI transactions from last month. Of these, 50 were confirmed fraudulent and 9,950 were legitimate. Separately, its AI model flagged 244 of the 10,000 transactions as suspicious. Of the 244 flagged transactions, 45 turned out to be genuinely fraudulent and 199 were false alarms on legitimate transactions.
Now ask: among transactions the AI flagged, what fraction were actually fraud? You do not need any new formula for this — you just restrict your attention to the 244 flagged transactions and count how many of those were fraud: 45 out of 244, or about 18.4%. That is a conditional probability: the probability of fraud, given that the transaction was flagged. It is written P(Fraud | Flagged), read "the probability of Fraud given Flagged."
Notice what just happened arithmetically. You took n(Fraud ∩ Flagged) = 45 and divided by n(Flagged) = 244. If you divide both the numerator and denominator by the total sample size 10,000, you get exactly the same ratio using probabilities instead of counts:
P(Fraud | Flagged) = n(Fraud ∩ Flagged) / n(Flagged)
= [n(Fraud ∩ Flagged)/10000] / [n(Flagged)/10000]
= P(Fraud ∩ Flagged) / P(Flagged)
This is the formal definition of conditional probability for any two events A and B, valid whenever P(B) > 0:
P(A | B) = P(A ∩ B) / P(B)
Read it as: "restrict the universe to B, then ask what fraction of that restricted universe is also A." Rearranging gives the multiplication rule, which you will use constantly: P(A ∩ B) = P(B) · P(A | B) = P(A) · P(B | A). Both expressions equal P(A ∩ B) because ∩ is symmetric — the order you intersect two sets doesn't matter, even though the order you condition on them does.
Independence — and a misconception CBSE and JEE students fall for constantly
Events A and B are independent if learning that B happened tells you nothing new about A — formally, P(A | B) = P(A), which combined with the multiplication rule gives the cleaner test: A and B are independent exactly when P(A ∩ B) = P(A) · P(B).
Misconception to kill right now: students routinely confuse "independent" with "mutually exclusive," treating them as roughly the same idea. They are nearly opposite. If A and B are mutually exclusive with P(A) > 0 and P(B) > 0, then P(A ∩ B) = 0 by definition — but P(A) · P(B) > 0 since both factors are positive. So P(A ∩ B) ≠ P(A) · P(B), which means mutually exclusive events with nonzero probability are never independent — knowing A happened tells you B definitely did not happen, which is about as much new information as you can get. This exact trap appears in JEE-level MCQs almost every year in some form: "If A and B are mutually exclusive, are they independent?" The answer is no, unless one of them has probability zero.
The Law of Total Probability: reconstructing the whole from its pieces
Go back to the bank. It doesn't usually hand you the count "244 flagged" directly — it hands you conditional rates from testing the model: the model correctly flags 90% of actual fraud (this is called its sensitivity, P(Flagged | Fraud) = 0.90), and it incorrectly flags 2% of legitimate transactions (its false-positive rate, P(Flagged | Legitimate) = 0.02). Given these rates and the true fraud prevalence P(Fraud) = 0.005 (50/10,000), can you reconstruct P(Flagged) — the overall chance any random transaction gets flagged — without a fresh count?
Yes, using the fact that {Fraud, Legitimate} partitions the sample space — every transaction is exactly one or the other, with no overlap. Any event B can be rebuilt as the sum of its overlaps with each piece of a partition:
P(B) = P(B | A1)·P(A1) + P(B | A2)·P(A2) + ... + P(B | An)·P(An)
where A1, ..., An partition the sample space. Applied here:
P(Flagged) = P(Flagged|Fraud)·P(Fraud) + P(Flagged|Legit)·P(Legit)
= (0.90)(0.005) + (0.02)(0.995)
= 0.0045 + 0.0199
= 0.0244
That matches the raw count exactly: 244 flagged out of 10,000 is 0.0244. The Law of Total Probability is what lets an AI system compute the overall probability of an observation (an alert firing, a word appearing, a pixel pattern showing up) purely from conditional rates it learned during training, without ever re-scanning the original data.
Deriving Bayes' theorem — the engine that flips a conditional probability around
Here is the actual problem an AI system faces. During training, it is easy to measure P(Flagged | Fraud) — take all the known fraud cases and see how many got flagged. But at the moment of decision, the system does not know whether a transaction is fraud; it only knows it was flagged. It needs the reverse conditional probability, P(Fraud | Flagged). Bayes' theorem is nothing more than the algebra that converts one into the other.
Start from the multiplication rule written both ways for events A and B:
P(A ∩ B) = P(A) · P(B | A)
P(A ∩ B) = P(B) · P(A | B)
The left sides are identical, so the right sides must be equal:
P(B) · P(A | B) = P(A) · P(B | A)
Divide both sides by P(B), assuming P(B) > 0:
P(A | B) = [P(B | A) · P(A)] / P(B)
That single line is Bayes' theorem. It says: to flip a conditional probability, multiply the "forward" conditional probability by the prior probability of A, then divide by the overall probability of B. Now substitute the Law of Total Probability for P(B), using the partition {A, A′} (A and its complement):
P(A | B) = P(B | A)·P(A) / [ P(B | A)·P(A) + P(B | A′)·P(A′) ]
This expanded form is the one you will actually use in problems, because P(B) is rarely given directly — you almost always have to build it from the partition. For a partition into more than two pieces A1, ..., An, the general statement is:
P(Ai | B) = P(B | Ai)·P(Ai) / [ Σj P(B | Aj)·P(Aj) ]
In Bayesian language, P(A) is called the prior (belief before seeing evidence), P(B | A) is the likelihood (how probable the evidence is under that hypothesis), and P(A | B) is the posterior (updated belief after seeing evidence). This vocabulary — prior, likelihood, posterior — is exactly the vocabulary machine learning papers use, because "training a classifier" is largely the process of estimating likelihoods from data so that, at prediction time, Bayes' theorem can convert them into posteriors.
Solving the opening problem — and meeting the base-rate fallacy
Now solve it properly. Let Fraud and Legit partition the transactions, and let Flagged be the evidence.
P(Fraud | Flagged) = P(Flagged|Fraud)·P(Fraud) / [P(Flagged|Fraud)·P(Fraud) + P(Flagged|Legit)·P(Legit)]
= (0.90)(0.005) / [(0.90)(0.005) + (0.02)(0.995)]
= 0.0045 / 0.0244
≈ 0.1844
Only about 18.4% — not 90%. A model with a genuinely strong 90% sensitivity and a genuinely low 2% false-positive rate still produces flagged alerts that are wrong roughly four times out of five. The diagram below shows exactly why: because genuine fraud (50 transactions) is so rare compared to legitimate transactions (9,950), even a small 2% false-positive rate applied to the enormous legitimate pool (199 false alarms) outnumbers the true fraud catches (45) in the flagged pile.
This gap between P(Flagged | Fraud) = 90% and P(Fraud | Flagged) = 18.4% is called the base-rate fallacy (also the prosecutor's fallacy in legal contexts): the mistake of treating P(B | A) as if it were equal to P(A | B). They are only equal when P(A) = P(B), which almost never happens. Every real fraud, disease-screening, and spam-detection system lives with this gap, and Bayes' theorem is the only correct way to close it — which is exactly why every serious fraud pipeline pairs an AI flag with a human review step rather than trusting the flag outright.
Naive Bayes: how a real spam filter combines multiple pieces of evidence
A single clue (one "flag") is the simplest case. Real AI classifiers combine many pieces of evidence — a spam filter looks at every word in an email, not just one. Suppose a training corpus shows P(spam) = 0.4 and P(ham) = 0.6 as priors, and the word likelihoods below (illustrative numbers, the kind a model estimates by counting word frequencies across thousands of labelled emails during training):
P("lottery" | spam) = 0.30 P("lottery" | ham) = 0.01
P("winner" | spam) = 0.20 P("winner" | ham) = 0.02
An email arrives containing both "lottery" and "winner." The naive assumption — the one that gives Naive Bayes its name — is that, given the class (spam or ham), the words are conditionally independent of each other. This is almost never literally true (words in real sentences are correlated), but it makes the computation tractable, and in practice it still works remarkably well:
Score(spam) ∝ P(spam) · P("lottery"|spam) · P("winner"|spam)
= 0.4 × 0.30 × 0.20 = 0.024
Score(ham) ∝ P(ham) · P("lottery"|ham) · P("winner"|ham)
= 0.6 × 0.01 × 0.02 = 0.00012
Normalize by dividing each score by their sum (0.02412), which is just the Law of Total Probability again, this time applied to the compound evidence "contains both words":
P(spam | both words) = 0.024 / 0.02412 ≈ 0.995 (about 99.5%)
P(ham | both words) = 0.00012 / 0.02412 ≈ 0.005 (about 0.5%)
Two individually weak signals ("lottery" alone only mildly favours spam; "winner" alone only mildly favours spam) combine multiplicatively into overwhelming evidence once both are present. This is the core mechanism, scaled up to tens of thousands of words and smarter feature representations, behind spam filters, sentiment classifiers, and many of the simplest working text classifiers in production AI systems today. You can verify the fraud calculation programmatically as well — the code below traces through the exact same arithmetic as the tree diagram:
def bayes_posterior(p_fraud, p_flag_given_fraud, p_flag_given_legit):
p_legit = 1 - p_fraud
numerator = p_flag_given_fraud * p_fraud
denominator = numerator + p_flag_given_legit * p_legit
return numerator / denominator
result = bayes_posterior(0.005, 0.90, 0.02)
print(round(result, 4))
# Trace: p_legit = 0.995
# numerator = 0.90 * 0.005 = 0.0045
# denominator = 0.0045 + 0.02*0.995 = 0.0045 + 0.0199 = 0.0244
# result = 0.0045 / 0.0244 = 0.18442622...
# Output: 0.1844
Bayesian updating: today's posterior is tomorrow's prior
The deepest reason Bayes' theorem underlies AI reasoning is that it composes cleanly over time. Once you compute P(Fraud | Flagged) = 0.1844 from the first alert, that number is no longer just an answer — it can become the new prior if a second, independent piece of evidence arrives (say, the transaction also originates from an unrecognised device). You would rerun the same formula, replacing P(Fraud) = 0.005 with the updated P(Fraud) = 0.1844, and combine it with the likelihood of an unrecognised device given fraud versus given legitimate use. This is exactly how a self-driving car's perception system fuses camera, radar, and lidar readings one after another, and how a large language model's internal representations get refined token by token — each new observation nudges a probability distribution rather than replacing it outright. Uncertainty is never eliminated in one step; it is narrowed, evidence by evidence.
Where this sits in your exams
- Conditional probability, the multiplication theorem, independence, the Law of Total Probability, and Bayes' theorem form Chapter 13 ("Probability") of the CBSE Class 12 Mathematics NCERT textbook — you are building that foundation early and rigorously here.
- JEE Main and JEE Advanced treat Bayes' theorem as a recurring, high-yield topic, frequently disguised as urn problems, defective-item problems, or multi-stage games rather than stated explicitly — recognise the "given that ___ happened, find the probability that ___" phrasing as your cue to reach for Bayes.
- BITSAT and olympiad-style combinatorics-probability problems reward exactly the base-rate-fallacy intuition you now have: always check whether a question is asking for P(A|B) or the easily-confused P(B|A).
- GATE-level computer science and data-science papers use this machinery directly inside Naive Bayes classifiers, Bayesian networks, and probabilistic reasoning questions — the vocabulary of prior, likelihood, and posterior transfers unchanged.
Formula sheet
Conditional probability: P(A|B) = P(A ∩ B) / P(B), P(B) > 0
Multiplication rule: P(A ∩ B) = P(A)·P(B|A) = P(B)·P(A|B)
Independence test: P(A ∩ B) = P(A)·P(B)
Law of Total Probability: P(B) = Σ P(B|Ai)·P(Ai) for a partition {Ai}
Bayes' theorem: P(Ai|B) = P(B|Ai)·P(Ai) / Σj P(B|Aj)·P(Aj)
Practice — attempt each fully before reading the answer
- A college has 60% boys and 40% girls. 5% of boys and 8% of girls are enrolled in a robotics elective. A student picked at random turns out to be enrolled in robotics. Find the probability the student is a girl.
- Events A and B satisfy P(A) = 0.3, P(B) = 0.4, P(A ∩ B) = 0.12. Are A and B independent? Justify using the definition, not intuition.
- A factory has two machines, M1 producing 70% of items with a 2% defect rate, and M2 producing 30% of items with a 5% defect rate. An item is picked at random and found defective. Find the probability it came from M2.
- Extend the spam filter example: a third word "urgent" has P("urgent"|spam) = 0.25 and P("urgent"|ham) = 0.05. If an email contains all three words ("lottery," "winner," "urgent"), recompute P(spam | all three words) using the naive independence assumption.
- A friend argues: "The weather AI said there's an 80% chance of rain today and it didn't rain, so the AI was wrong." Explain, using what you now know about probability, why this reasoning is flawed.
Answers: (1) Using Bayes' theorem with priors P(Boy)=0.6, P(Girl)=0.4 and likelihoods 0.05, 0.08: P(Robotics) = 0.6×0.05 + 0.4×0.08 = 0.03+0.032 = 0.062; P(Girl|Robotics) = 0.032/0.062 ≈ 0.516, so about 51.6%. (2) P(A)·P(B) = 0.3×0.4 = 0.12 = P(A∩B), so A and B are independent. (3) P(Defective) = 0.7×0.02 + 0.3×0.05 = 0.014+0.015 = 0.029; P(M2|Defective) = 0.015/0.029 ≈ 0.517, about 51.7%. (4) Score(spam) = 0.4×0.30×0.20×0.25 = 0.006; Score(ham) = 0.6×0.01×0.02×0.05 = 0.000006; sum = 0.006006; P(spam|evidence) ≈ 0.999, essentially certain. (5) An 80% forecast means rain was the more likely outcome, not the only possible one — a well-calibrated model that says "80% chance of rain" should be followed by rain on roughly 8 out of 10 such days, not every single day; one non-rainy day among many 80% forecasts is entirely consistent with (and expected from) a well-calibrated AI, not evidence that it is wrong.
Summary
Conditional probability P(A|B) = P(A∩B)/P(B) formalises "updating belief given new information." The Law of Total Probability rebuilds an overall probability from conditional pieces across a partition. Bayes' theorem is the algebraic consequence of writing the multiplication rule two ways and solving for the reversed conditional: P(A|B) = P(B|A)P(A) / P(B). It matters for AI specifically because training data naturally gives you forward likelihoods (P(evidence | hypothesis)) while real-time decisions need the reverse (P(hypothesis | evidence)) — fraud detectors, spam filters, medical-imaging classifiers, and Bayesian-updating robots all run this exact flip, often thousands of times per second. The single most important habit this chapter should leave you with is distinguishing P(A|B) from P(B|A) on sight — confusing them (the base-rate fallacy) is the single most common error in how humans, and occasionally even engineers, misread what a confident-sounding AI system is actually telling them.
Think About It
Think about this: How would you explain probability and bayes' theorem: how ai reasons under uncertainty to a friend who has never seen a computer? What real-world analogy would you use? Imagine you had to build a system using these concepts — what would be your first step? Try this: before moving on, write down three things you learned and one question you still have.