Skip to main content

← Math learning path

Quick reference · Math

Formula sheet

Every formula you will meet in the course, said in plain words, with where machine learning uses it. Use it to check a line, then return to the lesson that explains why.

Algebra and functions

FormulaIn wordsWhere ML uses it
y = m·x + bA straight line: m is the slope, b is where it crosses the y-axis.Linear regression: ŷ = w·x + b
m = (y₂ − y₁) / (x₂ − x₁)Slope: rise over run.The weight is a slope: change in prediction per unit of the input.
a^m · a^n = a^(m+n), (a^m)^n = a^(mn)Powers add when you multiply, multiply when you stack.Squared error, polynomial features.
log(a·b) = log a + log bLogs turn products into sums.Log-likelihood, log loss: sums are easier to optimise than products.
e^(ln x) = x, ln(e^x) = xExponential and log undo each other.Softmax and sigmoid.
σ(z) = 1 / (1 + e^(−z))Sigmoid: squeezes any number into 0 to 1.Logistic regression probabilities.
|a| = a if a ≥ 0, −a if a < 0Absolute value: distance from zero.Mean absolute error, L1 penalty.

Algebra and functions lessons →

Vectors and matrices

FormulaIn wordsWhere ML uses it
u·v = u₁v₁ + u₂v₂ + … + uₙvₙDot product: multiply matching entries and add.Every weighted sum: w·x.
‖v‖ = √(v₁² + v₂² + … + vₙ²)Length of a vector (L2 norm).Distances in kNN, ridge penalty.
‖v‖₁ = |v₁| + … + |vₙ|L1 norm: add the absolute entries.Lasso penalty.
cos θ = u·v / (‖u‖ ‖v‖)Cosine similarity: do they point the same way?Text and embedding similarity.
(AB)ᵢⱼ = row i of A · column j of BMatrix product. Inner sizes must match: (m×n)(n×p) = (m×p).A whole layer of a neural network: XW.
(AB)ᵀ = BᵀAᵀTranspose flips rows and columns; it reverses a product.Deriving normal equations.
det [[a, b], [c, d]] = ad − bc2×2 determinant: how much a matrix scales area.Invertibility check.
A v = λ vEigenvector: A only stretches it by λ.PCA, covariance structure.
w = (XᵀX)⁻¹ Xᵀ yLeast-squares weights in one step.Linear regression, the closed form.

Linear algebra lessons →

Calculus

FormulaIn wordsWhere ML uses it
f′(x) = lim (f(x+h) − f(x)) / hDerivative: the rate of change at one point.How much the loss changes when a weight changes.
d/dx xⁿ = n·xⁿ⁻¹Power rule.Squared error: d/dw w² = 2w.
d/dx (f + g) = f′ + g′, d/dx (c·f) = c·f′Sum and constant rules.Loss = sum over rows.
d/dx f(g(x)) = f′(g(x)) · g′(x)Chain rule: multiply the rates along the chain.Backpropagation.
d/dx eˣ = eˣ, d/dx ln x = 1/xTwo derivatives to remember.Log loss, softmax.
σ′(z) = σ(z)(1 − σ(z))Derivative of the sigmoid.Logistic regression gradient.
∇L = (∂L/∂w₁, …, ∂L/∂wₙ)Gradient: one slope per weight.The direction of steepest increase.
w ← w − η · ∇LGradient descent: step downhill. η is the learning rate.Training almost every model.
∫ₐᵇ f(x) dxArea under a curve between a and b.Probability density, expected values.

Derivatives lesson →

Probability

FormulaIn wordsWhere ML uses it
P(A) = favourable / totalChance when outcomes are equally likely.Class frequencies.
P(A or B) = P(A) + P(B) − P(A and B)Do not double count the overlap.
P(A and B) = P(A) · P(B) (independent)Independent events multiply.Naive Bayes assumption.
P(A | B) = P(A and B) / P(B)Chance of A once you know B happened.Every conditional model: P(churn | features).
P(A | B) = P(B | A) · P(A) / P(B)Bayes' rule: flip the condition.Naive Bayes, medical tests.
E[X] = Σ x · P(x)Expected value: the long-run average.Expected loss and expected cost.
Var(X) = E[(X − μ)²] = E[X²] − μ²Variance: average squared distance from the mean.Bias–variance.
Binomial: P(k) = C(n, k) pᵏ (1−p)ⁿ⁻ᵏk successes in n tries.Likelihood of coin-flip data.
Normal: f(x) = 1/(σ√(2π)) · e^(−(x−μ)²/(2σ²))The bell curve with mean μ and spread σ.Noise assumptions, z-scores.

Probability lessons →

Statistics

FormulaIn wordsWhere ML uses it
mean = (x₁ + … + xₙ) / nThe balance point.Baselines, centring.
median = middle value when sortedHalf above, half below. Ignores outliers.Skewed data such as prices.
s² = Σ(xᵢ − x̄)² / (n − 1)Sample variance. Divide by n for a whole population.Scaling features.
s = √s²Standard deviation: typical distance from the mean, in the data's units.Standardising.
z = (x − μ) / σHow many standard deviations from the mean.StandardScaler, outlier checks.
cov(x, y) = Σ(xᵢ − x̄)(yᵢ − ȳ) / (n − 1)Do they move together?PCA.
r = cov(x, y) / (sₓ · s_y)Correlation: covariance on a −1 to 1 scale.Feature screening. Not causation.
SE = s / √nStandard error of a mean: how much a sample mean wobbles.Error bars, tests.
95% interval ≈ x̄ ± 1.96 · SEA range built by a method that covers the truth 95% of the time.Reporting accuracy honestly.

Statistics lessons →

Hypothesis tests

FormulaIn wordsWhere ML uses it
H0: no difference. H1: there is one.State the boring claim and the claim you hope to support, before looking.Every test.
α = 0.05The false-alarm rate you accept, chosen in advance.Significance level.
z = (x − μ) / σDistance from the mean in standard deviations.Known spread or large samples.
t = (x̄ − μ₀) / (s / √n), df = n − 1Sample mean against a claim, in standard errors. Fatter tails than z.Small samples, unknown spread.
t = (x̄₁ − x̄₂) / √(s₁²/n₁ + s₂²/n₂)Two independent groups (Welch).A/B tests, group comparisons.
t = d̄ / (s_d / √n)Paired: the average of the differences over its standard error.Two models on the same folds.
p-value = P(statistic at least this extreme | H0 true)How surprising the data is if there is no difference. Not the chance H0 is true.Deciding: reject H0 if p < α.
Cohen's d = (x̄₁ − x̄₂) / pooled sEffect size: the gap in standard deviations. About 0.2 small, 0.5 medium, 0.8 large.Is it big enough to matter?
Type I = false alarm (rate α). Type II = a miss. Power = 1 − Type II.The two ways to be wrong, and the chance of catching a real effect.Planning sample size.
Bonferroni: use α / m for m testsKeep the overall false-alarm rate near α when you run many tests.Testing many features or models.

Normal, z, t and hypothesis tests →

Loss, metrics and regularisation

FormulaIn wordsWhere ML uses it
MAE = (1/n) Σ |yᵢ − ŷᵢ|Average miss, in the target's units.Regression reporting.
MSE = (1/n) Σ (yᵢ − ŷᵢ)², RMSE = √MSEAverage squared miss; punishes big misses.Training linear models.
R² = 1 − Σ(yᵢ − ŷᵢ)² / Σ(yᵢ − ȳ)²Share of the variation explained, against guessing the mean.Regression reporting.
log loss = −(1/n) Σ [y ln p + (1−y) ln(1−p)]Heavy penalty for confident wrong probabilities.Logistic regression, neural nets.
accuracy = (TP + TN) / allShare right.Balanced classes only.
precision = TP / (TP + FP), recall = TP / (TP + FN)Of those flagged, how many right; of the real ones, how many caught.Churn, fraud.
F1 = 2 · precision · recall / (precision + recall)One number balancing both.
Ridge: loss + λ Σ wⱼ², Lasso: loss + λ Σ |wⱼ|Penalise large weights to reduce overfitting.Regularisation.
error = bias² + variance + noiseWhere a model's mistakes come from.Choosing model flexibility.

Optimization lessons →

Information and likelihood

FormulaIn wordsWhere ML uses it
L(p) = pᵏ (1−p)ⁿ⁻ᵏLikelihood: how probable the data is under a story p.Maximum likelihood.
p̂ = k / nThe best p for k successes in n tries.Estimating a rate.
H(p) = −Σ pᵢ log₂ pᵢEntropy: average surprise, in bits.Decision-tree splits.
H(p, q) = −Σ pᵢ log₂ qᵢCross-entropy: cost of believing q when truth is p.Classification loss.
KL(p ‖ q) = H(p, q) − H(p)The extra cost of a wrong story.Comparing distributions.

Information bridge →