Skip to main content
© 2026 ePowerAI. All rights reserved.
CoursesContact
eAI
CoursesContact
Week 1: Probability Spaces and Events
Prob & Stats
01Week 1: Probability Spaces and Events
02Week 2: Random Variables and Distributions
03Week 3: Expectation, Variance, and Covariance
04Week 4: Conditioning and Independence
05Week 5: Bayes' Rule and Generative Classification
06Week 6: Multivariate Gaussians
07Week 7: Laws of Large Numbers and the CLT
08Week 8: Point Estimation — Maximum Likelihood
09Week 9: Bayesian Estimation and MAP
10Week 10: Bias, Variance, and Uncertainty
11Week 11: Information Theory for ML
12Week 12: Exponential Families (lite)
13Week 13: Graphical Models (lite)
14Week 14: Capstone — Probabilistic Language of ML
Week 01· Prob & Stats· Foundations20 min read

Week 1: Probability Spaces and Events

✦Learning Outcomes
  • Define sample space, event, and probability measure via the three axioms
  • Compute probabilities for simple finite spaces using additivity
  • Distinguish discrete listing of outcomes from continuous setups (densities deferred to Week 2)
  • Avoid the gambler's fallacy and non-additive mistakes in elementary examples
◆Prerequisites

Background: Linear Algebra complete (course index). High-school algebra and basic set notation; comfort with sums and (later) integrals.

Later weeks: This week establishes the axiomatic machinery that every subsequent week builds on — conditioning, random variables, and estimation all rest on the sample space and the three rules for PPP.

Why Probability for Machine Learning#

Machine learning operates on uncertainty. A classifier outputs a confidence score, not a deterministic label. A reinforcement learning agent acts in stochastic environments where the same action does not always produce the same result. A generative model learns a distribution over data, not a single point estimate.

Probability gives us the language to describe this uncertainty precisely. It tells us how to update beliefs when we see data (Week 5), how to quantify the spread of an estimator (Week 10), and how to measure the difference between distributions (Week 11). The courses on Reinforcement Learning and Generative Models speak this language fluently — this course builds your vocabulary from the ground up.

The approach we take is axiomatic: we agree on three simple rules that any coherent assignment of probabilities must obey. From those rules, everything else follows.

Sample Spaces and Events#

Every probabilistic model starts with a sample space Ω\OmegaΩ — the set of all possible outcomes of an experiment.

Examples:

  • Toss a fair coin: Ω={H,T}\Omega = \{\text{H}, \text{T}\}Ω={H,T}.
  • Roll a six-sided die: Ω={1,2,3,4,5,6}\Omega = \{1, 2, 3, 4, 5, 6\}Ω={1,2,3,4,5,6}.
  • Measure tomorrow's temperature (in °C): Ω=R\Omega = \mathbb{R}Ω=R (or an interval).
  • Two coin tosses: Ω={HH,HT,TH,TT}\Omega = \{\text{HH}, \text{HT}, \text{TH}, \text{TT}\}Ω={HH,HT,TH,TT}.

An event is a subset of Ω\OmegaΩ — a collection of outcomes about which we can ask "what is the probability?".

Example — die roll. Let Ω={1,2,3,4,5,6}\Omega = \{1, 2, 3, 4, 5, 6\}Ω={1,2,3,4,5,6}. The event "roll an even number" is E={2,4,6}E = \{2, 4, 6\}E={2,4,6}. The event "roll at least 5" is F={5,6}F = \{5, 6\}F={5,6}.

Set operations on events (since events are sets, set language applies):

  • Union A∪BA \cup BA∪B: the event that AAA or BBB occurs (or both).
  • Intersection A∩BA \cap BA∩B: the event that AAA and BBB both occur.
  • Complement Ac=Ω∖AA^c = \Omega \setminus AAc=Ω∖A: the event that AAA does not occur.
  • Disjoint (mutually exclusive) events: A∩B=∅A \cap B = \varnothingA∩B=∅, meaning they cannot both happen on the same realisation.

For the die example: E∩F={6}E \cap F = \{6\}E∩F={6} (even and at least 5), E∪F={2,4,5,6}E \cup F = \{2, 4, 5, 6\}E∪F={2,4,5,6}.

Kolmogorov Axioms#

A probability measure PPP assigns a number in [0,1][0, 1][0,1] to each event. Andrey Kolmogorov (1933) gave three axioms that any valid PPP must satisfy:

  1. Non-negativity. For every event AAA, P(A)≥0P(A) \ge 0P(A)≥0.
  2. Normalisation. P(Ω)=1P(\Omega) = 1P(Ω)=1 — some outcome must occur.
  3. Countable additivity (finite version). If A1,A2,…,AkA_1, A_2, \ldots, A_kA1​,A2​,…,Ak​ are pairwise disjoint, then
P(A1∪A2∪⋯∪Ak)=P(A1)+P(A2)+⋯+P(Ak).P(A_1 \cup A_2 \cup \cdots \cup A_k) = P(A_1) + P(A_2) + \cdots + P(A_k).P(A1​∪A2​∪⋯∪Ak​)=P(A1​)+P(A2​)+⋯+P(Ak​).

For most of this course we use the finite version of axiom 3: probabilities of mutually exclusive events simply add. The infinite (countable) version handles sequences, but the intuition is identical.

What the axioms give us — useful consequences:

  • P(∅)=0P(\varnothing) = 0P(∅)=0 (the impossible event).
  • Complement rule: P(Ac)=1−P(A)P(A^c) = 1 - P(A)P(Ac)=1−P(A).
  • Monotonicity: If A⊆BA \subseteq BA⊆B, then P(A)≤P(B)P(A) \le P(B)P(A)≤P(B).
  • Inclusion-exclusion (two events):
P(A∪B)=P(A)+P(B)−P(A∩B).P(A \cup B) = P(A) + P(B) - P(A \cap B).P(A∪B)=P(A)+P(B)−P(A∩B).

The inclusion-exclusion formula corrects for double-counting: adding P(A)+P(B)P(A) + P(B)P(A)+P(B) counts the intersection twice, so we subtract it once.

Worked example. In a class of 100 students, 60 study calculus (AAA), 45 study linear algebra (BBB), and 20 study both. What is the probability a randomly chosen student studies at least one of the two subjects?

P(A∪B)=P(A)+P(B)−P(A∩B)=60100+45100−20100=0.85.P(A \cup B) = P(A) + P(B) - P(A \cap B) = \frac{60}{100} + \frac{45}{100} - \frac{20}{100} = 0.85.P(A∪B)=P(A)+P(B)−P(A∩B)=10060​+10045​−10020​=0.85.

So 85% study at least one. The complement rule gives P(neither)=1−0.85=0.15P(\text{neither}) = 1 - 0.85 = 0.15P(neither)=1−0.85=0.15.

Finite Spaces and Counting#

When Ω\OmegaΩ is finite and every outcome is equally likely, probability reduces to counting:

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

where ∣⋅∣|\cdot|∣⋅∣ denotes cardinality (number of elements). This is the "classical" definition of probability — but it only works when the equiprobable assumption is justified (fair coins, fair dice, well-shuffled cards, random sampling).

Worked example — two dice. Roll two fair six-sided dice (36 equally likely ordered pairs). What is the probability that the sum is 7?

The outcomes that sum to 7 are {(1,6),(2,5),(3,4),(4,3),(5,2),(6,1)}\{(1,6), (2,5), (3,4), (4,3), (5,2), (6,1)\}{(1,6),(2,5),(3,4),(4,3),(5,2),(6,1)} — six outcomes. So

P(sum=7)=636=16.P(\text{sum} = 7) = \frac{6}{36} = \frac{1}{6}.P(sum=7)=366​=61​.

Inclusion-exclusion with counting (two events):

For two events AAA and BBB in a finite equiprobable space:

∣A∪B∣=∣A∣+∣B∣−∣A∩B∣|A \cup B| = |A| + |B| - |A \cap B|∣A∪B∣=∣A∣+∣B∣−∣A∩B∣

Dividing through by ∣Ω∣|\Omega|∣Ω∣ recovers the probability inclusion-exclusion formula above. The three-event version is:

∣A∪B∪C∣=∣A∣+∣B∣+∣C∣−∣A∩B∣−∣A∩C∣−∣B∩C∣+∣A∩B∩C∣.|A \cup B \cup C| = |A| + |B| + |C| - |A \cap B| - |A \cap C| - |B \cap C| + |A \cap B \cap C|.∣A∪B∪C∣=∣A∣+∣B∣+∣C∣−∣A∩B∣−∣A∩C∣−∣B∩C∣+∣A∩B∩C∣.

The pattern: add singles, subtract pairs, add triples — alternating signs so every outcome in the union is counted exactly once.

Discrete vs Continuous Setup#

So far we have thought of Ω\OmegaΩ as a finite or countably infinite set (e.g., N\mathbb{N}N). In that case we can list the outcomes and assign a probability p(ω)p(\omega)p(ω) to each ω∈Ω\omega \in \Omegaω∈Ω, with ∑ωp(ω)=1\sum_{\omega} p(\omega) = 1∑ω​p(ω)=1. For any event AAA, P(A)=∑ω∈Ap(ω)P(A) = \sum_{\omega \in A} p(\omega)P(A)=∑ω∈A​p(ω).

But many quantities of interest — temperature, height, the weight of a neural network — are continuous. The sample space is an interval or all of R\mathbb{R}R. Here the list-and-sum approach breaks down: any single real number has probability zero (think of picking a point on a line — there are uncountably many of them, so each gets measure zero).

For continuous spaces, probability is assigned via a density function f(x)≥0f(x) \ge 0f(x)≥0 that integrates to 1 over the space:

P(a≤X≤b)=∫abf(x) dx.P(a \le X \le b) = \int_a^b f(x)\, dx.P(a≤X≤b)=∫ab​f(x)dx.

This is the subject of Week 2, where we introduce random variables, PMFs, PDFs, and CDFs systematically. For now, the key distinction is:

| Discrete | Continuous | |---|---| | Ω\OmegaΩ is finite or countable | Ω\OmegaΩ is an interval or R\mathbb{R}R | | P(A)=∑ω∈Ap(ω)P(A) = \sum_{\omega \in A} p(\omega)P(A)=∑ω∈A​p(ω) | P(A)=∫Af(x) dxP(A) = \int_A f(x)\, dxP(A)=∫A​f(x)dx | | Single outcomes can have positive probability | Single outcomes have probability zero | | Motivating examples: coins, dice, cards | Motivating examples: measurements, sensor readings |

The axiomatic framework (Kolmogorov's three rules) works in both settings. The only difference is whether we sum or integrate to accumulate probability over an event.

Warning — Do not conflate the two. In a continuous setting, P(X=3.7)P(X = 3.7)P(X=3.7) is 0, even though the density f(3.7)f(3.7)f(3.7) may be positive. Density is not probability — it is probability per unit. Week 2 makes this crisp.

Exercise · Fill in the blank

In a survey, 40% of respondents own a dog (A), 30% own a cat (B), and 15% own both. Using inclusion-exclusion, what percentage owns a dog or a cat (or both)?


Knowledge check#

Question 1 of 4

Which of Kolmogorov's axioms would be violated if we assigned P(A) = −0.1 to some event?

Non-negativity
Normalisation
Countable additivity
Complement rule

Browser lab#

Simulate die rolls and compare empirical frequencies to the axiom-based probabilities of events.

python · runs in browser
import numpy as np
import matplotlib.pyplot as plt

def roll_die(n):
    return np.random.randint(1, 7, size=n)

n_rolls = 6000
rolls = roll_die(n_rolls)

events = {
    "Even (2,4,6)": (rolls % 2 == 0),
    "≥ 5 (5,6)": (rolls >= 5),
    "Prime (2,3,5)": np.isin(rolls, [2, 3, 5]),
    "Divisible by 3 (3,6)": (rolls % 3 == 0),
}

true_probs = {"Even (2,4,6)": 0.5, "≥ 5 (5,6)": 1/3,
              "Prime (2,3,5)": 0.5, "Divisible by 3 (3,6)": 1/3}

fig, axes = plt.subplots(2, 2, figsize=(8, 7))
for ax, (name, mask) in zip(axes.flat, events.items()):
    empirical = mask.sum() / n_rolls
    ax.bar(["Axiom (true)", "Empirical"], [true_probs[name], empirical],
           color=["tab:blue", "tab:orange"])
    ax.set_ylim(0, 1)
    ax.set_title(name)
    ax.set_ylabel("Probability")

fig.suptitle(f"Empirical vs True Probabilities ({n_rolls} rolls)", fontsize=13)
plt.tight_layout()
plt.show()

print("Empirical frequencies:")
for name, mask in events.items():
    print(f"  {name}: {mask.sum() / n_rolls:.4f}  (true: {true_probs[name]:.4f})")
Next →
Week 2: Random Variables and Distributions
On this page
  • Why Probability for Machine Learning
  • Sample Spaces and Events
  • Kolmogorov Axioms
  • Finite Spaces and Counting
  • Discrete vs Continuous Setup
  • Knowledge check
  • Browser lab