QuiddityML

Math for ML

Linear algebra, calculus, probability, and information theory, as ML uses them. Posts are listed in the order the ideas build on each other.

Math toolkit and notation

Math toolkit and notation How to read the math notation in ML papers Machine learning papers write their formulas with a small set of symbols: big sigma and pi, argmin and argmax, hats and bars over letters, a left arrow, and shape declarations like W ∈ ℝ^(m×n). This post explains what each one means and shows the PyTorch line that does the same thing. 7 October 2026 · 7 min read Math toolkit and notation Exponents and logarithms for machine learning Logarithms show up in most machine learning loss functions because a log turns a product into a sum. This post covers the exponent and log rules, what an inverse function is, and why training works with log-likelihood instead of multiplying probabilities, with PyTorch code. 7 October 2026 · 6 min read Math toolkit and notation Sine and cosine for machine learning Sine and cosine are the coordinates of a point on a circle of radius 1, and they repeat every full turn. This post explains the unit circle, the identity sin² + cos² = 1, and how sine and cosine features let a model see that hour 23 and hour 0 are one hour apart, with PyTorch code. 7 October 2026 · 4 min read Math toolkit and notation Big-O notation for machine learning Big-O notation describes how the work an algorithm does grows as its input gets bigger. This post explains what it keeps and what it drops, the growth rates you will meet (O(1), O(log n), O(n), O(n log n), O(n²)), and why an all-pairs method that is fine on a thousand items fails on a million. 7 October 2026 · 3 min read

Linear algebra

Linear algebra Vectors and matrices for machine learning Machine learning stores data as scalars, vectors, matrices and tensors. This post explains each one, how shapes and indexing work in PyTorch, adding and scaling vectors, the transpose, and the identity, diagonal and symmetric matrices. 7 October 2026 · 5 min read Linear algebra Span, basis and linear independence explained The span of a set of vectors is every point you can reach by scaling and adding them, a basis is the smallest set that reaches a whole space, and linear independence says no vector in the set is redundant. This post explains all three with 2D examples, what they mean for features in a dataset, and how to check them in PyTorch. 7 October 2026 · 4 min read Linear algebra Multicollinearity explained: why correlated features break linear regression Multicollinearity is when two or more features in a dataset carry almost the same information. This post explains why that makes a linear model's weights unstable even when its predictions look fine, shows it happening in PyTorch, and covers what to do about it. 8 October 2026 · 5 min read Linear algebra Matrix multiplication explained: the linear map view, dot products and outer products Matrix multiplication combines two grids of numbers by pairing the rows of one with the columns of the other. This post explains how to compute it by hand, why the shapes have to line up, how a matrix transforms vectors, and two other ways to read the same product, with PyTorch code for each. 8 October 2026 · 7 min read Linear algebra Hadamard product vs matrix multiplication: * vs @ in PyTorch The Hadamard product multiplies two matrices position by position, which is what * does in PyTorch, while matrix multiplication combines rows with columns, which is what @ does. This post compares the two on the same numbers, explains the shape rules for each, and shows where the Hadamard product is used in models. 8 October 2026 · 5 min read Linear algebra Solving systems of linear equations with Gaussian elimination How to solve a 2x2 and a 3x3 system of equations by hand with row operations, how to tell from the reduced rows whether there is one solution, none, or infinitely many, and the same steps in PyTorch. 8 October 2026 · 7 min read Linear algebra Determinant, trace and inverse: when a matrix is singular How to compute a determinant for 2x2 and 3x3 matrices, what a zero determinant means for inverting a matrix and solving equations, why torch.linalg.solve beats torch.linalg.inv in code, and where the trace shows up. 8 October 2026 · 7 min read Linear algebra Rank, column space and null space explained How to find the rank of a matrix by hand, what the column space and null space say about whether Ax = b has a solution, why a large weight matrix can hold far fewer independent directions than its size, and how to check all of it in PyTorch. 8 October 2026 · 6 min read Linear algebra The dot product explained, and what it measures in machine learning How to compute a dot product by hand, what its sign says about two vectors, how it relates to the angle between them, and the three PyTorch calls that compute it. 9 October 2026 · 5 min read Linear algebra Cosine similarity explained: the angle between two vectors How to compute cosine similarity by hand and in PyTorch, what scores of 1, 0 and -1 mean, and when to compare embeddings with it instead of the raw dot product. 9 October 2026 · 5 min read Linear algebra Vector norms and distances: L1, L2, Euclidean vs Manhattan How to compute the L1, L2 and L-infinity norms by hand, when Euclidean and Manhattan distance give different answers, why L1 and L2 penalties shrink weights differently, and the PyTorch calls for each. 9 October 2026 · 6 min read Linear algebra Orthogonality explained: orthogonal matrices, orthonormal bases, and projections How to tell when two vectors or a whole matrix are orthogonal, why the inverse of an orthogonal matrix is its transpose, how to project one vector onto another, and how Gram-Schmidt builds an orthonormal basis, with PyTorch code for each. 9 October 2026 · 7 min read Linear algebra Invariance vs equivariance, and why convolution is translation equivariant The two equations that separate an invariant function from an equivariant one, worked examples with rotations and shifts, which network layers have which property, and PyTorch checks you can run on a convolution, a pooling step, and a shuffled hidden layer. 9 October 2026 · 4 min read Linear algebra Least squares explained: linear regression as a projection, and the normal equation How least squares becomes a projection onto a column space, how the normal equations come out of one orthogonality condition, what the Gram matrix is and when it fails, and how to fit a line in PyTorch. 9 October 2026 · 5 min read Linear algebra Eigenvalues and eigenvectors explained How to find the eigenvalues and eigenvectors of a matrix, how they relate to its determinant and trace, how a change of basis rewrites a vector or a matrix, and how eigendecomposition turns a matrix into per-axis scaling, with PyTorch code throughout. 9 October 2026 · 6 min read Linear algebra Positive definite matrices explained, with the Cholesky and QR factorizations How to test whether a matrix is positive definite, semi-definite, negative definite or indefinite, why every covariance matrix passes the semi-definite test, and when to use the QR and Cholesky factorizations, with PyTorch code for each. 9 October 2026 · 6 min read Linear algebra The condition number explained: why some problems are numerically unstable How to compute the condition number of a matrix from its eigenvalues, what the Rayleigh quotient says about the largest and smallest eigenvalue, and two PyTorch experiments that show a large condition number amplifying small errors and slowing gradient descent. 9 October 2026 · 5 min read Linear algebra SVD explained: singular value decomposition and low-rank approximation What the three factors of an SVD do to a vector, how to read a matrix's rank off its singular values, and how keeping only the largest few gives the closest possible low-rank copy of the matrix, with PyTorch code for each. 10 October 2026 · 6 min read Linear algebra What is a tensor? Shapes, batches, and tensor operations How to read a tensor's shape, why models process a whole batch with one matrix multiplication, and when to use reshape, squeeze, sum and permute, with PyTorch code for each and the reshape mistake that silently scrambles attention heads. 10 October 2026 · 5 min read Linear algebra Broadcasting in NumPy and PyTorch explained How to tell in advance whether two shapes can be combined and what shape comes out, how to make a vector stretch across rows or across columns, and how to build a table of every pairwise difference without a loop, with PyTorch code for each. 10 October 2026 · 5 min read Linear algebra Einsum explained with examples (torch.einsum) How to read an einsum string like 'bik,bkj->bij', which letters get summed and which stay, and how to write the dot product, matrix multiplication, transpose, batched matmul, elementwise product, and outer product with torch.einsum. 11 October 2026 · 6 min read

Calculus and optimization

Calculus and optimization Derivatives for machine learning: limits, continuity, and the derivative How the derivative is built from a limit, when a function has no derivative at a point (and why ReLU has a kink at 0), the seven rules that cover most expressions, and how to get the sigmoid's derivative in one line, with Python to check each result. 11 October 2026 · 6 min read Calculus and optimization Partial derivatives and gradients explained How to take the derivative of a function with several inputs one input at a time, how those derivatives stack into the gradient, and why stepping against the gradient lowers a loss fastest, with worked examples and PyTorch checks. 11 October 2026 · 6 min read Calculus and optimization The chain rule explained for machine learning How to differentiate a function that feeds into another function, how the rule extends to several paths and to vector-valued layers, and how to check the result in PyTorch. 12 October 2026 · 6 min read Calculus and optimization The Jacobian matrix explained How to build the Jacobian of a function with several inputs and outputs, why the gradient is a one-row Jacobian, and how to use it to chain layers and estimate output sensitivity, with PyTorch checks. 12 October 2026 · 5 min read Calculus and optimization Matrix calculus for deep learning: the gradient of a linear layer, by hand A gentle walk through the few vector and matrix gradients deep learning reuses, with small examples you can check by hand, ending with the backward pass of a linear layer worked out with real numbers and checked in PyTorch. 12 October 2026 · 9 min read Calculus and optimization Automatic differentiation explained: how autograd works How PyTorch gets the gradient of a loss for millions of parameters in one backward pass, why it walks the computation graph from the output back to the inputs, and when forward mode is the better fit, with code you can run. 13 October 2026 · 8 min read Calculus and optimization The Hessian matrix explained, and the eigenvalue test for minima How to compute the Hessian of a function by hand, why it is symmetric, and how its eigenvalues tell a minimum from a maximum or a saddle point, with PyTorch code to check each step. 13 October 2026 · 8 min read Calculus and optimization Taylor series for machine learning: linearization and why gradient descent works How to approximate a function near a point with its gradient and Hessian, how far you can trust that approximation, and what it says about why a small gradient descent step lowers the loss, with worked numbers and PyTorch code. 13 October 2026 · 7 min read Calculus and optimization Convex functions explained (and why neural network losses are not convex) How to check whether a function is convex with a chord, the Hessian or a short list of known shapes, what Jensen's inequality says, and what a convex optimization problem looks like, with PyTorch code for the chord and Hessian checks. 14 October 2026 · 10 min read Calculus and optimization Local minima and saddle points in deep learning How to find the points where a function's gradient is zero, tell a minimum from a maximum or a saddle with the second-derivative test, and see in PyTorch why gradient descent can stall at a saddle. 14 October 2026 · 7 min read

Probability and statistics

Probability and statistics Random variables and probability distributions explained: PMF vs PDF How a die roll and a classifier's output are both described by a distribution, the two rules every distribution follows, and why a density can be larger than 1 while a probability cannot, with PyTorch code. 14 October 2026 · 5 min read Probability and statistics Dependent vs independent variables in machine learning Which part of a dataset is X and which is y, the other names each one goes by (features, labels, targets, predictors), and how they look as PyTorch tensors. 15 October 2026 · 5 min read Probability and statistics Joint, marginal, and conditional probability explained, with independence How to read a joint probability table, get a marginal by adding a row, get a conditional by dividing, test two variables for independence, and factor any joint with the chain rule, with PyTorch code. 15 October 2026 · 10 min read Probability and statistics Bayes' theorem explained with an example Where the formula comes from, what the prior, likelihood and posterior mean, and a spam filter example worked by hand and in PyTorch, including how the prior changes the answer. 15 October 2026 · 6 min read Probability and statistics Common probability distributions in ML: Bernoulli, binomial, Poisson, Beta Which distribution fits which question, the formula and mean of each one worked with real numbers, and how to check them in PyTorch. 16 October 2026 · 10 min read Probability and statistics The Gaussian (normal) distribution explained What the mean and standard deviation do to the bell curve, how to standardize any Gaussian to z-scores, and why code works with the log-density, with every step checked in PyTorch. 16 October 2026 · 6 min read Probability and statistics Degrees of freedom explained Why sample variance divides by n - 1, what the degrees of freedom of Student's t and chi-squared control, and a PyTorch simulation that shows dividing by n runs low. 16 October 2026 · 5 min read Probability and statistics Kernel density estimation explained How KDE turns a handful of data points into a smooth density by hand and in PyTorch, how the bandwidth h changes the result, and where KDE is used for visualizing data and spotting anomalies. 17 October 2026 · 7 min read Probability and statistics CDF, percentiles, and quantiles explained How to compute a CDF for discrete and continuous data, how to read a median or a 95th percentile off it, and how to do both in PyTorch on real latency data. 17 October 2026 · 7 min read Probability and statistics Expected value and variance explained, with conditional expectation How to compute the expected value and variance of a distribution by hand and in PyTorch, what happens to them when you shift or scale the data, and why a model trained with squared error predicts a conditional mean. 17 October 2026 · 8 min read Probability and statistics Covariance vs correlation How to compute covariance and correlation by hand and in PyTorch, why correlation is the one to compare across datasets, and how covariance decides whether the uncertainty of two quantities adds up or cancels. 17 October 2026 · 6 min read Probability and statistics The multivariate Gaussian, covariance matrices, and Mahalanobis distance How to read and estimate a covariance matrix and how much a full or diagonal one costs to learn, plus how Mahalanobis distance flags outliers, with PyTorch code for each step. 17 October 2026 · 8 min read Probability and statistics The law of large numbers and the central limit theorem explained Why sample averages settle toward the true mean and why their error is bell-shaped with a spread of sigma over root n, plus when neither result holds, with PyTorch simulations of each. 17 October 2026 · 7 min read Probability and statistics Standard error and confidence intervals explained How to put an error bar on an average, such as a validation accuracy or a mean latency, how to compute it by hand and in PyTorch, and what 95% confidence does and does not promise. 18 October 2026 · 7 min read Probability and statistics Hypothesis testing and p-values: is model A really better than model B? How to tell whether a gap between two models is real or noise, what a p-value does and does not mean, one-sided vs two-sided tests, and why running many tests produces false winners, with PyTorch checks. 18 October 2026 · 8 min read Probability and statistics MLE vs MAP estimation How maximum likelihood and maximum a posteriori estimation each pick a parameter from data, why MAP gives a sensible answer where MLE overreacts, and how a prior turns into L2 or L1 regularization, with PyTorch examples. 18 October 2026 · 8 min read Probability and statistics Bayesian inference explained: priors, posteriors, and conjugate priors How to turn a prior and a likelihood into a posterior, and how to read uncertainty and predictions off it. The PyTorch examples also update a Beta prior by counting. 19 October 2026 · 7 min read Probability and statistics Bias and variance of an estimator, and why sample variance divides by n minus 1 How to measure an estimator's bias and variance with a simulation, how they add up to mean squared error, and how to choose between the two sample variance formulas in PyTorch. 19 October 2026 · 6 min read Probability and statistics Monte Carlo methods explained: Monte Carlo estimation, importance sampling, and rejection sampling What error to expect from an average of random samples, and how importance sampling and rejection sampling handle targets that are hard to sample from. The PyTorch examples also show why both struggle in high dimensions. 19 October 2026 · 7 min read Probability and statistics Markov chain Monte Carlo (MCMC) explained How the Metropolis-Hastings rule decides each step, why the unknown normalizing constant never has to be computed, and how many independent draws a correlated chain is worth, with a working sampler in PyTorch. 20 October 2026 · 6 min read Probability and statistics The reparameterization trick explained How to build a Gaussian sample from a mean, a Cholesky factor and standard normal noise, why that lets gradients reach the mean, and how PyTorch's rsample does it for you. 20 October 2026 · 5 min read Probability and statistics Bootstrap resampling explained How to get a standard error and a 95% interval for a median, an accuracy or any other statistic without deriving a formula, with the PyTorch code and the mistakes to avoid. 20 October 2026 · 5 min read

Information theory

Numerical computation