Summarizing a distribution in a few numbers
A probability distribution contains an enormous amount of information. But to reason efficiently, we need compact summaries: where is the "center"? What is the "spread"? Are the variables related to each other? These are the moments of a distribution, and they are at the heart of analyzing ML models.
Expectation: the expected average value
Definition
The expectation is the weighted average of all possible values, each weighted by its probability:
- Discrete case:
- Continuous case:
Analogy
Imagine a loaded die. If the 6 comes up twice as often as the other faces, the expectation is no longer 3.5 but shifts upward. The expectation is the "center of gravity" of the distribution: if you placed weights on a ruler at each possible value, proportional to their probability, the balance point would be exactly the expectation.
Essential properties
- Linearity: , always, even if and are not independent
- Expectation of a constant:
- Expectation of a function: (law of the unconscious statistician)
In ML
Expectation appears everywhere:
- The average loss over a batch is an empirical expectation:
- Training with SGD estimates the expected gradient using a random sample
- The ELBO of VAEs is an expectation under the variational distribution
Variance: measuring the spread
Definition
Variance measures how far values stray from the mean:
The second formula is often more practical for calculations.
Analogy
Two archers each shoot 100 arrows. Both hit the center on average (same expectation). But the first archer's arrows are clustered near the center, while the second's are scattered across the entire target. The second has a much larger variance.
Properties
- Non-negative: , and only if is constant
- Scaling: (the square matters!)
- Sum of independent variables: if and are independent
Standard deviation: the square root of variance
The standard deviation shares the usefulness of variance for measuring spread, but with a practical advantage: it's expressed in the same units as . If is in meters, is in meters (variance would be in square meters).
In ML, when we say "the weights are initialized with a standard deviation of 0.02," we mean in .
Covariance: relationships between variables
Definition
Covariance measures how two variables vary together:
Interpretation
- : when increases, tends to increase too
- : when increases, tends to decrease
- : no linear relationship (but there can be a nonlinear relationship!)
Correlation: normalized covariance
Correlation is always between and , making it easier to interpret than raw covariance.
Covariance matrix
For a random vector
When you have a vector , the covariance matrix gathers all pairwise covariances:
It's a matrix, symmetric and positive semi-definite.
Geometric properties
The covariance matrix describes the "shape" of the distribution:
- Its eigenvalues give the variance in each principal direction
- Its eigenvectors give the axes of that shape
In ML: PCA
Principal Component Analysis (PCA) consists exactly of diagonalizing the covariance matrix. The eigenvectors associated with the largest eigenvalues are the directions of greatest variance in the data. Projecting onto these directions lets you reduce dimensionality while keeping the maximum amount of information.
In ML: multivariate Gaussian
The multivariate Gaussian is entirely defined by its mean vector and covariance matrix. That's why these two quantities are enough to describe the latent space of a VAE.
The bias-variance tradeoff
The central problem of ML
When you train a model, the prediction error decomposes into three terms:

Bias: systematic error
Bias measures how much the model is wrong on average. A model that's too simple (a straight line for curved data) has high bias. It systematically misses the target, regardless of the training data.
Variance: sensitivity to data
Variance measures how much predictions change when you change the training data. A model that's too complex (a degree-100 polynomial for 10 data points) has high variance. It fits the training data perfectly but changes drastically with a slightly different dataset.
The tradeoff
- Simple model: high bias, low variance (underfitting)
- Complex model: low bias, high variance (overfitting)
- Optimal model: the right balance between the two

Practical translation
| Technique | Effect on bias | Effect on variance |
|---|---|---|
| Increase model size | Decreases | Increases |
| Regularization (L2, dropout) | Slightly increases | Decreases |
| More training data | Unchanged | Decreases |
| Ensemble methods (bagging) | Unchanged | Decreases |
| Boosting | Decreases | Slightly increases |
The deep learning paradox
Classical theory predicts that very large models should have enormous variance and overfit severely. Yet, overparameterized neural networks often generalize very well. This phenomenon, sometimes called "double descent," is an active research topic. The current intuition is that gradient descent acts as an implicit regularizer, favoring "simple" solutions even in an immense parameter space.

Key takeaways
- Expectation is the expected average value, fundamental for defining loss functions
- Variance measures spread, essential for understanding the reliability of estimates
- Covariance captures linear relationships between variables
- The covariance matrix is at the heart of PCA and Gaussian modeling
- The bias-variance tradeoff explains why a model that's neither too simple nor too complex is necessary
- Deep learning challenges the classical view of this tradeoff with the double descent phenomenon
Where this is used. The standard deviation of a group of scores sits at the heart of GRPO, and the bias-variance tradeoff is the subject of overfitting.