Probability Fundamentals
Part of the AI Engineer Roadmap
In short
A classifier saying '92% spam' is speaking probability. Before you can trust, tune or explain model outputs, you need the basic rules of chance.
Random variables, events, and basic probability rules — the language models use to express uncertainty in predictions.

Think of it like this
The toss before a match
Before every cricket match, a coin decides who bats first. Nobody knows the next toss, but over a whole season, heads comes up about half the time. Probability is that long-run share. One toss is unpredictable, thousands of tosses are not.
Watch it happen
Ten tosses, counting heads
1/4After 1 toss: 1 head. Share of heads = 1/1 = 1.0. Way off 0.5, but it's only one toss.
The big ideas
What you need to know
Between 0 and 1
P = 0 means impossible, P = 1 means certain. All outcomes of one event add up to 1.
Complement rule
P(not A) = 1 − P(A). If rain has a 0.3 chance, no rain has 0.7.
Or means add (if they can't overlap)
Rolling a 1 or a 2: 1/6 + 1/6 = 1/3. If events can overlap, subtract the overlap once.
And means multiply (if independent)
Two sixes in a row: 1/6 × 1/6 = 1/36. Only valid when one result doesn't affect the other.
See it in code
Walk through the code
1import random2random.seed(42)3 4rolls = [random.randint(1, 6) for _ in range(60_000)]5print(rolls.count(6) / len(rolls)) # close to 1/6, about 0.1676 7even = sum(r % 2 == 0 for r in rolls) / len(rolls)8print(even) # close to 0.59 10pairs = [(random.randint(1, 6), random.randint(1, 6)) for _ in range(36_000)]11both_six = sum(a == 6 and b == 6 for a, b in pairs) / len(pairs)12print(both_six, 1 / 36) # both near 0.0281/4Fixing the seed makes the random numbers repeat each run, so results are reproducible.
Simulation is a great way to check a probability rule. If your formula and the simulation disagree, one of them is wrong.
Save yourself the pain
Common mistakes
Oops
Thinking after five heads in a row, tails is 'due'.
Do this instead
Each fair toss is independent. The coin has no memory, so the next toss is still 50-50.
Oops
Multiplying probabilities of events that affect each other.
Do this instead
Only multiply directly when events are independent. Otherwise use conditional probability: P(A and B) = P(A) × P(B given A).
Your mission
Check the rules by simulation
Quick check
A model says P(spam) = 0.85 for an email. What is P(not spam)?
Go deeper
- 1Review basic probability rules: complement, union, intersection, conditional probability.
- 2Practice computing probabilities on simple discrete examples (dice, cards).
- 3Learn independence vs. conditional dependence between events.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.