What probability actually promises
A probability is a number between zero and one that we attach to an event â a yes-or-no question about an experiment that has not been run yet. The promise is deliberately modest: probability does not describe your particular coin, but how often heads would appear if you flipped it forever under identical conditions. That repeated-experiment view, called the frequentist interpretation, is the one that matches how most machine learning metrics are computed. A classifier reporting ninety percent accuracy will be right about nine times in ten on future inputs.
The practical reason every practitioner needs this foundation is that models are trained and evaluated under uncertainty. Cross-entropy loss is a negative log-likelihood, dropout approximates a posterior over weights, and an A/B test returns a p-value. Each of those ideas rests on the same three axioms. When a metric looks wrong, the fastest debugging route is to ask which probability the metric is actually estimating.
The axioms and their quiet consequences
Kolmogorov's axioms are short enough to memorise and strong enough to generate the entire theory. For a sample space â the set of all possible outcomes â and any event contained in it, the axioms say that is never negative, that the probability of the whole space equals one, and that probabilities of mutually exclusive events add. That third axiom extends to countably infinite families, which is what lets us sum over infinite sample spaces without running into contradictions.
Everything else is a consequence rather than a new assumption. The complement rule follows by partitioning the space into and its negation, so . Monotonicity follows because a larger event contains extra disjoint pieces that each carry non-negative probability. The general addition rule subtracts the intersection once, because summing the two separate probabilities counts that overlap twice.
| Rule | Formula | When it applies |
|---|---|---|
| Complement | Any event | |
| Addition | Any two events | |
| Mutual exclusion | and cannot co-occur | |
| Multiplication | Any conditioning | |
| Union bound | Any collection, no independence needed |
The union bound deserves special attention because it is the one inequality you can always reach for: it requires neither independence nor a distributional assumption, which is why it appears in concentration inequalities, generalisation bounds, and any argument of the form "the probability that something bad happens somewhere is small."
Counting before you compute
Once outcomes are equally likely, computing a probability reduces to counting favourable outcomes and dividing by the total. Two formulas cover most textbook problems. Permutations count ordered selections, so arranging distinct items out of gives . Combinations ignore order, dividing that count by to give the binomial coefficient. The factorial grows explosively: fifty-two choose five is already about two and a half million, which is why hand enumeration fails quickly and code does not.
Three counting patterns show up repeatedly in machine learning problems. Sampling with replacement from categories gives sequences of length . Distributing identical items into distinct bins is the stars-and-bars count . Multiset permutations divide by the factorial of each repeated count, so the number of distinct anagrams of a word is the total factorial over the product of factorials of its letter frequencies.
from math import comb, perm, factorial
def arrangements(n, k):
"""Ordered selection without replacement."""
return perm(n, k)
def subsets(n, k):
"""Unordered selection without replacement."""
return comb(n, k)
def anagram_count(word):
"""Distinct permutations of a word with repeated letters."""
counts = {}
for ch in word.lower():
counts[ch] = counts.get(ch, 0) + 1
total = factorial(len(word))
for c in counts.values():
total //= factorial(c)
return total
print(arrangements(10, 3)) # 720 ordered triples
print(subsets(10, 3)) # 120 unordered triples
print(anagram_count("probability")) # 907200 distinct anagrams
# Inclusion-exclusion for three events
def prob_union(pa, pb, pc, pab, pac, pbc, pabc):
return pa + pb + pc - pab - pac - pbc + pabc
print(round(prob_union(0.5, 0.4, 0.3, 0.2, 0.15, 0.1, 0.05), 4))
The inclusion-exclusion expression in that snippet is the systematic fix for double counting. For two events you subtract one overlap; for three you subtract the three pairwise overlaps and add back the triple overlap, because subtracting pairwise terms removed it three times and it must be restored once. The signs alternate, and the pattern continues for any finite number of events.
Conditioning, independence, and Bayes' rule
Conditional probability is what probability becomes when you learn something. restricts attention to the sub-space where occurred and renormalises so the remaining probabilities still sum to one. From that definition, the multiplication rule and then Bayes' rule follow in two lines: the joint probability can be factorised in either order, so , and dividing by gives the update formula.
Two distinctions trip up almost everyone at first. Independence means â knowing one event tells you nothing about the other. Mutual exclusion means the intersection is empty, so the events cannot happen together. Mutually exclusive events are maximally dependent: if you learn that happened, you know did not. Treating them as independent is a substantive modelling claim that must be justified, not a default.
Bayes' rule also exposes why rare events stay rare even after a positive test. With a one percent prevalence, ninety-five percent sensitivity, and a five percent false positive rate, the posterior probability of disease after a positive result is only about sixteen percent â because the false positives among the healthy majority outnumber the true positives among the sick. Getting the arithmetic right changes the decision, which is the entire point of the framework.
Checking closed forms by simulation
Whenever a probability has a clean formula, a Monte Carlo estimate is an independent check on it â and for problems with no clean formula, simulation is often the only tool available. The pattern never changes: generate many independent draws that respect the problem's structure, record how often the event occurs, and compare the empirical frequency with the theoretical value. The law of large numbers guarantees agreement in the limit, and the standard error of the estimate falls like one over the square root of the number of trials.
import numpy as np
def birthday_probability(n, days=365, trials=200_000, seed=0):
"""Monte Carlo estimate that n people share a birthday."""
rng = np.random.default_rng(seed)
shared = 0
for _ in range(trials):
birthdays = rng.integers(0, days, size=n)
if np.unique(birthdays).size < n:
shared += 1
return shared / trials
def exact_birthday(n, days=365):
"""Closed form: 1 minus the probability all birthdays differ."""
if n > days:
return 1.0
no_collision = 1.0
for i in range(n):
no_collision *= (days - i) / days
return 1.0 - no_collision
def dice_sum_probability(target, faces=6, trials=200_000, seed=1):
"""Probability that two dice sum to target."""
rng = np.random.default_rng(seed)
a = rng.integers(1, faces + 1, size=trials)
b = rng.integers(1, faces + 1, size=trials)
return np.mean(a + b == target)
for n in (10, 23, 40):
print(n, round(exact_birthday(n), 4), round(birthday_probability(n), 4))
print("P(sum is 7) =", round(dice_sum_probability(7), 4))
The birthday problem is the classic surprise: twenty-three people already give better than even odds of a shared birthday, and forty push the probability past ninety percent. The closed form multiplies the conditional probabilities that each new person avoids all previous birthdays, and the simulation lands within a fraction of a percent of it.
When exact answers are out of reach
Real problems rarely hand you a finite sample space you can enumerate. In those cases, inequalities turn a question about one event into a question about quantities you can estimate. Markov's inequality bounds the chance that a non-negative random variable exceeds a threshold by dividing its mean by that threshold. Chebyshev's inequality converts variance into a statement about deviation from the mean: the probability of straying more than standard deviations is at most .
These bounds are loose because they assume nothing about shape, and that is their value: they are valid for every distribution, so they work when normality is hopeless. They also explain why variance matters so much in estimation, since a smaller variance buys a tighter probabilistic guarantee. For sums of many weakly dependent terms, the central limit theorem replaces these crude bounds with a normal approximation, which is where the normal distribution earns its central role in statistics.
Mistakes that break probability arguments
Common Mistakes
Assuming independence because two events feel unrelated
Fix: Check the definition: verify P(A and B) equals P(A) times P(B) from data or from the generative story.
Confusing mutually exclusive with independent
Fix: Mutually exclusive events are dependent by construction; if one occurs the other cannot.
Using the addition rule without subtracting the overlap
Fix: Apply P(A or B) = P(A) + P(B) minus P(A and B) unless the events are disjoint.
Ordering problems solved with combinations when order matters
Fix: Ask whether rearranging a favourable outcome produces a different outcome; if yes, use permutations.
Quoting a positive predictive value without the base rate
Fix: Apply Bayes' rule with prevalence; rare conditions produce more false positives than true ones.
Best Practices
- Write the sample space explicitly before assigning any probabilities.
- Prefer the complement rule for at least-one questions; it usually turns a long sum into one subtraction.
- Use the union bound when dependence is unknown, because it never requires an independence assumption.
- Verify closed-form answers with a short simulation whenever the computation is cheap.
- Report the prior or base rate alongside any conditional probability you publish.
Probability foundations at a glance
Where to go next
- Conditional Probability â conditioning and the law of total probability.
- Bayes' Theorem â medical testing and spam filtering worked in full.
- Random Variables and Distributions â turning events into quantities we can average.