Stochastic gradient methods
Separate conditional unbiasedness, variance, and step-size schedules when replacing an expensive gradient with a random estimate.
On this page
The question for today
What you’ll understand
- State conditional unbiasedness relative to the iterate history.
- Calculate one-step mean and variance for a noisy quadratic update.
- Explain variance reduction by independent averaging and the limits of constant steps.
A full gradient can require inspecting an entire dataset or averaging over an enormous collection of possible outcomes. Stochastic gradient methods trade an exact expensive direction for a cheaper random one. The randomness is useful only under stated assumptions: an estimate can be unbiased yet extremely noisy, or precise but systematically biased. Understanding these distinctions explains why a training curve can jump upward even while a method makes progress in expectation.
Condition on what the algorithm already knows
Let the history contain all previous iterates and sampled information. A standard stochastic-gradient model requires the next estimate to have conditional mean equal to the true gradient at the current iterate. This is stronger and more useful than merely saying that the error averages to zero over an unspecified experiment. The current iterate depends on earlier randomness, so the relationship between a new sample and that history is central to the analysis.
For a finite sum of losses, sampling an index uniformly and taking that term's gradient gives an unbiased estimate of the average gradient, provided sampling is appropriate for the conditioned history. Nonuniform sampling usually needs inverse-probability weighting. Sampling without replacement across an epoch can be beneficial, but its conditional behavior differs from independent sampling, so a proof assuming fresh independent indices should not be applied without checking the change in sampling mechanism.
Descent competes with noise
Apply the smoothness upper bound to a random step and then take conditional expectations. The exact-gradient descent term survives, while a variance penalty appears with the square of the step size. For a fixed nonzero step and persistent noise, this penalty generally prevents arbitrary precision. The iteration may enter a neighborhood rather than settle at one exact point. Smaller steps reduce the neighborhood but also reduce the speed of meaningful movement.
Averaging b independent, identically distributed unbiased estimates divides their variance by b. Correlation can remove that benefit, and a larger batch costs more evaluations. In classical stochastic-approximation settings, decreasing schedules with divergent total step length and finite total squared step length help balance persistent exploration against accumulated noise. Those two sums alone are not a universal convergence theorem: regularity, stability or boundedness, and noise conditions still have to be supplied.
Identify what a deterministic picture leaves out
For the unit quadratic, writing a stochastic gradient as x plus zero-mean noise makes the distinction especially clear. The conditional mean contracts like ordinary gradient descent, but the next squared error includes an extra variance contribution. A mean trajectory near zero therefore does not imply that individual runs are near zero. Reporting only averaged parameter coordinates can hide substantial fluctuations and poor realized objective values.
The interactive lab contains no random sampling: it displays the exact deterministic recurrence. Use it to predict the conditional mean of one stochastic update at the same x and η, then calculate the extra variance below. It cannot demonstrate stochastic fluctuations, minibatch variance, or a stochastic convergence theorem. In actual experiments, record seeds, sampling rules, learning-rate schedules, and distributions across runs so the empirical claim matches the mathematical model.
Work it through
The mean moves closer while uncertainty remains
For at x=2, use with equally likely noise or . Take η=1/2 and compute the next mean, variance, and expected objective.
If ξ=1, the gradient estimate is three and the next point is . If ξ=−1, the estimate is one and the next point is . Both outcomes have probability one half.
The conditional mean is , matching the deterministic mean update . Deviations from the mean are −0.5 and 0.5, so the variance is 0.25.
The expected objective is . Evaluating f only at the mean would give 0.5 and miss the variance contribution .
The average point contracts to 1, but expected objective is 0.625 because noise leaves variance. Function of the mean and mean function value are different.
The living notebook
Explore the model
Interactive lab · optimization
A deterministic conditional-mean baseline
Set x₀=2 and η=0.5, then predict the first exact update before stepping. Compare its value with the hand-computed noisy example. The lab has no random samples or stochastic gradient estimates; only the one-step conditional mean shares this update formula.
- Position x0
- 2
- Objective x²/2
- 2
- Iteration behavior
- Stable step
Gradient descent on f(x) = x²/2: xₙ = (1 − η)ⁿx₀. Playback advances two discrete iterations per second. Values outside |x| ≤ 4 are explicitly reported. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forA deterministic mean update omits the variance that contributes to expected squared error and expected objective value.
Pause & reason
Check your understanding
Your turn
Try it yourself
Repeat the noisy update calculation at x=0 with η=0.2 and noise ξ=±1 equally likely. Compute the next mean and expected objective, and explain why zero is not absorbing.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
The true gradient is zero, but each noisy gradient estimate is nonzero. The two possible next points are symmetric about zero.
Compare with the solution
The next points are −0.2 and 0.2, so their mean is zero. Each objective value is , making the expected value 0.02 as well. Persistent gradient noise moves individual iterates away from the optimum despite zero conditional mean; a constant step does not make the minimizer absorbing in this model.
Keep the idea
Take it with you
- Conditional unbiasedness refers to the current iterate and the algorithm's history.
- Variance contributes a step-size-squared penalty even when the mean direction is correct.
- Independent averaging, diminishing steps, and repeated-run reporting address different aspects of stochastic behavior.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.