AI Knowledge Tree

Sample spaces, events, and the Kolmogorov axioms

Set up a probability space from the three axioms and compute probabilities of compound events.

⏱ 28 min

Before any random variable, distribution, or expectation, probability needs a foundation: what is the set of things that can happen, and what rule assigns each of them a number between 0 and 1? Kolmogorov's three axioms answer this[1, 2], and every later result is a consequence of them.

Sample space and events

The sample space Ω\Omega is the set of all possible outcomes of an experiment. A single roll of a die has Ω={1,2,3,4,5,6}\Omega = \{1, 2, 3, 4, 5, 6\}; a coin flip has Ω={H,T}\Omega = \{H, T\}.

An event is a subset A⊆ΩA \subseteq \Omega: a collection of outcomes we want to assign a probability to. "The die shows an even number" is the event A={2,4,6}A = \{2, 4, 6\}. Events combine with set operations: A∪BA \cup B ("AA or BB"), A∩BA \cap B ("AA and BB"), and Ac=Ω∖AA^c = \Omega \setminus A ("not AA").

For technical reasons (uncountable sample spaces have non-measurable subsets), the events form a σ\sigma-algebra F\mathcal{F}[2]: a collection of subsets closed under complement and countable union, containing Ω\Omega. For a finite or countable Ω\Omega one can take F\mathcal{F} to be all subsets, and the technical layer never intrudes.

The three axioms

A probability measure is a function P:F→RP: \mathcal{F} \to \mathbb{R} satisfying:

  1. Nonnegativity: P(A)≥0P(A) \ge 0 for every event AA.
  2. Normalization: P(Ω)=1P(\Omega) = 1.
  3. Countable additivity: for pairwise disjoint events A1,A2,…A_1, A_2, \dots (meaning Ai∩Aj=∅A_i \cap A_j = \varnothing when i≠ji \neq j), P ⁣(⋃i=1∞Ai)=∑i=1∞P(Ai).P\!\left(\bigcup_{i=1}^\infty A_i\right) = \sum_{i=1}^\infty P(A_i).

The triple (Ω,F,P)(\Omega, \mathcal{F}, P) is a probability space. Everything else is derived.

Consequences

Probability of the complement. Since AA and AcA^c are disjoint and their union is Ω\Omega, axioms 2 and 3 give P(A)+P(Ac)=P(Ω)=1P(A) + P(A^c) = P(\Omega) = 1, so

P(Ac)=1−P(A).P(A^c) = 1 - P(A).

Setting A=ΩA = \Omega gives P(∅)=0P(\varnothing) = 0.

Monotonicity. If A⊆BA \subseteq B, write B=A∪(B∖A)B = A \cup (B \setminus A) as a disjoint union. Then P(B)=P(A)+P(B∖A)≥P(A)P(B) = P(A) + P(B \setminus A) \ge P(A) by nonnegativity.

Inclusion-exclusion. For any two events,

P(A∪B)=P(A)+P(B)−P(A∩B).P(A \cup B) = P(A) + P(B) - P(A \cap B).

Derivation. Split A∪BA \cup B into three disjoint pieces: A∖BA \setminus B, B∖AB \setminus A, and A∩BA \cap B. Additivity gives P(A∪B)=P(A∖B)+P(B∖A)+P(A∩B)P(A \cup B) = P(A \setminus B) + P(B \setminus A) + P(A \cap B). Also P(A)=P(A∖B)+P(A∩B)P(A) = P(A \setminus B) + P(A \cap B) and similarly for BB. Substituting and collecting terms yields the formula: the intersection is added twice when summing P(A)+P(B)P(A) + P(B), so it is subtracted once.

Equally likely outcomes

When Ω\Omega is finite and every outcome is equally likely, axioms 2 and 3 force P({ω})=1/∣Ω∣P(\{\omega\}) = 1/|\Omega|, so for any event

P(A)=∣A∣∣Ω∣.P(A) = \frac{|A|}{|\Omega|}.

Probability reduces to counting. This is the classical model behind dice, cards, and uniform sampling.

Check it on arrays

A probability is the long-run fraction of trials in which an event occurs. Monte Carlo sampling makes the axioms tangible: simulate many trials, count, and watch the empirical frequencies obey the rules above.

python · numpy
import numpy as np

rng = np.random.default_rng(0)
N = 1_000_000

# Two independent dice
d1 = rng.integers(1, 7, size=N)
d2 = rng.integers(1, 7, size=N)

A = (d1 + d2 == 7)          # event: sum is 7
B = (d1 == d2)              # event: doubles

pA = A.mean()
pB = B.mean()
pAB = (A & B).mean()        # sum 7 AND doubles is impossible
pA_or_B = (A | B).mean()

print(f"P(A)        = {pA:.4f}   (exact 6/36 = {6/36:.4f})")
print(f"P(B)        = {pB:.4f}   (exact 6/36 = {6/36:.4f})")
print(f"P(A and B)  = {pAB:.4f}   (exact 0)")
print(f"P(A or B)   = {pA_or_B:.4f}")

# Inclusion-exclusion: P(A or B) = P(A) + P(B) - P(A and B)
print(f"incl-excl   = {pA + pB - pAB:.4f}")

# Complement rule: P(not A) = 1 - P(A)
print(f"P(not A)    = {(~A).mean():.4f}   1 - P(A) = {1 - pA:.4f}")

The empirical frequencies match the counting probabilities, and inclusion-exclusion and the complement rule hold to sampling precision.

Exercises

Exercise 1. A fair die is rolled once. Let A={2,4,6}A = \{2, 4, 6\} (even) and B={4,5,6}B = \{4, 5, 6\} (greater than 3). Compute P(A∪B)P(A \cup B) two ways: by counting the union directly, and by inclusion-exclusion.

Solution

Step 1. By counting: A∪B={2,4,5,6}A \cup B = \{2, 4, 5, 6\} has 4 outcomes out of 6, so P(A∪B)=4/6=2/3P(A \cup B) = 4/6 = 2/3.

Step 2. By inclusion-exclusion: P(A)=3/6P(A) = 3/6, P(B)=3/6P(B) = 3/6, and the intersection A∩B={4,6}A \cap B = \{4, 6\} has P(A∩B)=2/6P(A \cap B) = 2/6. Then

P(A∪B)=36+36−26=46=23.P(A \cup B) = \frac{3}{6} + \frac{3}{6} - \frac{2}{6} = \frac{4}{6} = \frac{2}{3}.

Both routes agree, as the inclusion-exclusion derivation guarantees.

Exercise 2. Prove Boole's inequality (the union bound) for two events: P(A∪B)≤P(A)+P(B)P(A \cup B) \le P(A) + P(B), using only the axioms and the results derived in this lesson.

Solution

Step 1. Inclusion-exclusion gives the exact identity

P(A∪B)=P(A)+P(B)−P(A∩B).P(A \cup B) = P(A) + P(B) - P(A \cap B).

Step 2. By nonnegativity (axiom 1), P(A∩B)≥0P(A \cap B) \ge 0. Subtracting a nonnegative quantity can only decrease the right side:

P(A)+P(B)−P(A∩B)≤P(A)+P(B).P(A) + P(B) - P(A \cap B) \le P(A) + P(B).

Step 3. Chaining the two lines,

P(A∪B)≤P(A)+P(B),P(A \cup B) \le P(A) + P(B),

with equality exactly when P(A∩B)=0P(A \cap B) = 0 (the events overlap on a probability-zero set). The bound trades the exact overlap correction for a one-sided estimate.

Exercise 3 (code). Simulate one million rolls of two fair dice. Estimate P(A∪B)P(A \cup B) for A={sum=8}A = \{\text{sum} = 8\} and B={at least one 6}B = \{\text{at least one } 6\}, and check that the Monte Carlo estimate matches the inclusion-exclusion value computed from the empirical pieces.

Solution
python · numpy
import numpy as np

rng = np.random.default_rng(2)
N = 1_000_000
d1 = rng.integers(1, 7, size=N)
d2 = rng.integers(1, 7, size=N)

A = (d1 + d2 == 8)              # sum is 8
B = (d1 == 6) | (d2 == 6)       # at least one 6

pA, pB, pAB = A.mean(), B.mean(), (A & B).mean()
direct = (A | B).mean()
incl_excl = pA + pB - pAB

assert np.isclose(direct, incl_excl, atol=1e-12)
print("P(A or B) direct:", round(direct, 4),
      " incl-excl:", round(incl_excl, 4))

The direct union frequency and the inclusion-exclusion reconstruction agree exactly, since both are computed from the same simulated trials.

With a probability space in place, the next lesson attaches numbers to outcomes through random variables.


References

  1. [1]Wasserman, L. (2004). All of Statistics. Springer. Ch. 1, sample spaces and the probability axioms. doi:10.1007/978-0-387-21736-9↩
  2. [2]Billingsley, P. (1995). Probability and Measure (3rd ed.). Wiley. The measure-theoretic treatment of probability spaces and σ\sigma-algebras.↩