Deep Learning Note 2: Sums, Variance, and Alignment
One of the most useful mathematical ideas for understanding deep learning begins with a surprisingly simple question:
Imagine standing at the origin of a number line and taking a step to the left or right depending on the outcome of a fair coin toss. After taking 100 steps, you have certainly travelled 100 units, but you are unlikely to be 100 units away from where you started. Some steps undo the progress made by others. This distinction between the total amount of activity and its net effect is what we want to understand.

Figure 1: A random walk illustrating the difference between distance travelled and net displacement.
Understanding mean and variance
Suppose we repeat this experiment thousands of times. Sometimes we finish to the left of the origin, sometimes to the right. Since both directions are equally likely, our average final position approaches zero. This average is called the mean, commonly denoted by . However, the mean alone tells us very little about how far we have wandered. Whether we take ten steps or a million, our expected final position remains zero, even though a million steps give us considerably more opportunity to wander away from the origin. We therefore need another quantity that describes how widely our outcomes are spread around their mean.

Figure 2: Three distributions sharing the same mean but having progressively larger spreads.
We begin by measuring each outcome's deviation from the mean, . Simply averaging these deviations would bring us back to zero, since positive and negative deviations cancel. Instead, we square them before averaging. This gives us a quantity called variance.
Since squaring changes the units of our measurement, we take the square root to return to the original scale. This gives us the standard deviation, denoted by .
The mean describes where our numbers tend to live, while the standard deviation describes how far they typically wander from that centre.
The hidden interactions inside a sum
Now consider two random quantities, and , each with zero mean and variance . We want to understand the typical magnitude of their sum. Since both have zero mean, their sum also has zero mean, and its variance is simply the expected squared sum.
Squaring this expression reveals something particularly interesting:
The first two terms describe the individual contributions of the numbers, while the third describes their relationship with one another. When both numbers have the same sign, their product is positive, increasing the squared magnitude of the sum. When their signs differ, their product is negative, reducing it. The cross term therefore captures whether the two quantities reinforce or cancel one another.

Figure 3: A geometric decomposition of a squared sum, highlighting individual contributions and cross terms.
Two different worlds
Imagine that and are outcomes of two independent fair coin tosses, each producing either or . There are four equally likely possibilities.
| Interaction | ||
|---|---|---|
The positive and negative interactions balance perfectly in expectation. Consequently,
Only the individual squared contributions survive. More generally, for uncorrelated quantities with variance ,
Now imagine a slightly different experiment. Instead of tossing two independent coins, we toss a single coin and repeat its outcome twice. Each individual quantity still has exactly the same mean and variance, but their relationship has changed. They always share the same sign, meaning their interaction is positive whenever the outcome is nonzero.
More generally, when both quantities are copies of the same zero-mean random variable with variance ,
Therefore,
Notice that we have not changed the statistical properties of the individual quantities. We have only changed how they relate to one another, and that alone has changed the magnitude of their combined effect.

Figure 4: An animation comparing independent coin tosses with perfectly aligned coin tosses.
Why this becomes remarkable at scale
Let us extend this idea from two quantities to quantities. When we square their sum, every quantity interacts with every other quantity.
There are only individual squared contributions, but there are ordered cross terms, counting both orders of each pair. As increases, the number of interactions grows much faster than the number of individual contributions.

Figure 5: An expanding matrix of pairwise products, showing how off-diagonal interactions rapidly outnumber diagonal contributions.
When the quantities are uncorrelated, the cross terms average to zero, leaving only the individual contributions. When the quantities are perfectly aligned, every interaction reinforces the others.
| Uncorrelated | Perfectly aligned | |
|---|---|---|
| Variance | ||
| Standard deviation |
This is the origin of two fundamentally different scaling laws:

Figure 6: An animated comparison of square-root growth and linear growth as the number of contributions increases.
The world in between
Of course, most interesting systems are neither completely uncorrelated nor perfectly aligned. Suppose every pair of quantities shares a small positive correlation . The variance of their sum becomes
Or, equivalently,
Even a tiny positive correlation can become significant when thousands of quantities interact. For instance, with 10,000 quantities of unit variance, a pairwise correlation of just increases the standard deviation of their sum from 100 to approximately 1,005. Individually, these relationships appear almost insignificant. Collectively, they can dominate the behaviour of the entire system.
Figure 7: A visualization showing how even a small positive correlation changes the scaling behaviour of a sum.
The central idea worth carrying forward is that the magnitude of a sum depends not only on the magnitude of its individual contributions, but also on the relationships between them. Uncorrelated contributions tend to cancel, while aligned contributions reinforce one another. As the number of quantities grows, even a small amount of alignment can produce a surprisingly large collective effect.
We will encounter this same mathematical idea repeatedly when studying high-dimensional vectors, attention, normalization, residual connections, and gradient updates. Although these mechanisms may initially appear unrelated, understanding cancellation and alignment gives us a common starting point for exploring them.