Blame

e0287e lugonthier 2026-07-02 15:52:15
Add new content and images for machine learning and mathematics modules - Added images for regularization and high-dimensional inference. - Introduced Support Vector Machines (SVM) module with detailed explanations and images. - Created Decision Trees and Ensemble Methods module with comprehensive content and illustrations. - Added a Mathematics overview module and a refresher on mathematical concepts essential for machine learning. - Included SVG diagrams for Bayes' rule and multivariate Gaussian distribution.
1
# 1. Mathematical refresher
2
3
This module gathers the mathematical tools the rest of the course leans on: a little linear algebra, the language of expectation and covariance, the multivariate Gaussian, and the four probability quantities (likelihood, prior, posterior, evidence) that the next module turns into a way of reasoning. It is a reference to return to, not a full treatment.
4
5
**Objectives**
6
- Recall the vector and matrix operations used throughout: dot product, matrix-vector product, transpose, inverse, and norm.
7
- Define expectation, variance, and covariance, and assemble the covariance matrix.
8
- Write the multivariate Gaussian density and read its shape from the covariance.
9
- Name the likelihood, prior, posterior, and evidence, and relate them by Bayes' rule.
10
11
## 1.1 Linear algebra
12
13
A feature vector lives in $\mathbb{R}^n$ and a dataset stacks such vectors into a matrix. The dot product of two vectors sums their elementwise products:
14
15
$$\boxed{ x^T y = \sum_{i=1}^{n} x_i\, y_i }$$
16
17
A matrix $A$ maps a vector by the matrix-vector product $Ax$, the transpose $A^T$ swaps rows and columns, and the inverse $A^{-1}$ (when it exists) undoes $A$, so $A^{-1}A = I$. The Euclidean norm measures length:
18
19
$$\boxed{ \lVert x \rVert_2 = \sqrt{x^T x} }$$
20
21
A square matrix is symmetric if $A = A^T$, and positive semidefinite if $x^T A x \ge 0$ for every $x$. Covariance matrices, which appear next, are always symmetric and positive semidefinite.
22
23
## 1.2 Expectation and variance
24
25
The expectation is the probability-weighted average of a random variable, a sum in the discrete case and an integral in the continuous one:
26
27
$$\boxed{ \mathbb{E}[X] = \sum_x x\, p(x) \qquad \mathbb{E}[X] = \int x\, p(x)\, dx }$$
28
29
Expectation is linear, $\mathbb{E}[aX + b] = a\,\mathbb{E}[X] + b$. The variance measures spread around the mean $\mu = \mathbb{E}[X]$:
30
31
$$\boxed{ \mathrm{Var}(X) = \mathbb{E}\!\left[(X - \mu)^2\right] = \mathbb{E}[X^2] - \mu^2 }$$
32
33
## 1.3 Covariance and the covariance matrix
34
35
Covariance measures how two variables move together:
36
37
$$\boxed{ \mathrm{Cov}(X, Y) = \mathbb{E}\!\left[(X - \mu_X)(Y - \mu_Y)\right] }$$
38
39
For a random vector $x \in \mathbb{R}^n$ with mean $\mu$, the covariance matrix collects every pairwise covariance:
40
41
$$\boxed{ \Sigma = \mathbb{E}\!\left[(x - \mu)(x - \mu)^T\right], \qquad \Sigma_{ij} = \mathrm{Cov}(x_i, x_j) }$$
42
43
Its diagonal holds the per-feature variances, it is symmetric, and it is positive semidefinite. Off-diagonal entries record correlation between features.
44
45
## 1.4 The multivariate Gaussian
46
47
The Gaussian is the default model for continuous noise and for smooth clouds of points. In $n$ dimensions it is parameterized by a mean vector $\mu$ and a covariance matrix $\Sigma$:
48
49
$$\boxed{ p(x) = \frac{1}{(2\pi)^{n/2}\,|\Sigma|^{1/2}} \exp\!\left(-\tfrac{1}{2}(x - \mu)^T \Sigma^{-1}(x - \mu)\right) }$$
50
51
Its contours of equal density are ellipsoids centred at $\mu$, and the covariance $\Sigma$ sets their spread and orientation.
52
53
![The multivariate Gaussian for three covariance shapes](/en/Mathematics/01%20Mathematical%20refresher/a/multivariate-gaussian.png)
54
55
*A spherical covariance gives circular contours, a diagonal one gives axis-aligned ellipses, and off-diagonal terms tilt them, encoding correlation between the features.*
56
57
*Remark:* the quadratic form $(x - \mu)^T \Sigma^{-1}(x - \mu)$ is the squared Mahalanobis distance, the natural distance once the data has a covariance structure.
58
59
## 1.5 Likelihood, prior, posterior, and evidence
60
61
Almost every model in this course reasons about parameters $\theta$ given data $D$. Four quantities recur, and they are tied together by Bayes' rule:
62
63
$$\boxed{ p(\theta \mid D) = \frac{p(D \mid \theta)\, p(\theta)}{p(D)} }$$
64
65
- The **likelihood** $p(D \mid \theta)$ is how probable the data is under a given $\theta$.
66
- The **prior** $p(\theta)$ is what we believed about $\theta$ before seeing the data.
67
- The **posterior** $p(\theta \mid D)$ is the updated belief after seeing it.
68
- The **evidence** $p(D) = \int p(D \mid \theta)\, p(\theta)\, d\theta$ normalizes the posterior so it integrates to one.
69
70
![Bayes' rule combines prior and likelihood into the posterior](/en/Mathematics/01%20Mathematical%20refresher/a/bayes-rule.svg)
71
72
*The posterior is proportional to the likelihood times the prior, divided by the evidence that makes it a proper distribution.*
73
74
*Remark:* the evidence is a constant with respect to $\theta$, so for many tasks it can be ignored and only the numerator $p(D \mid \theta)\, p(\theta)$ matters.
75
76
*These tools underpin the [Machine Learning](/en/Machine%20Learning) course, where probability, loss functions, and models are built on them.*
77
78
---
79
Next: [Course overview](/en/Mathematics)