Stochastic optimization practice
Allow about five minutes per exercise and briefly justify each answer. Exercises 1–10 cover streaming SGD and acceleration. Exercises 11–12 are optional.
Throughout, denotes expectation and denotes the Euclidean norm.
Streaming samples and SGD
1. Optimal order at a kink
A newsvendor chooses a real-valued order quantity and pays , where . Demand is , , or , with probabilities , , and , respectively. Find the slope of immediately to the left and right of . Use the slopes to decide if minimizes .
Solution to exercise 1
Immediately left of , the slope is . Immediately right of , it is . The slope crosses zero, so by convexity is the unique minimizer. Equivalently, the subdifferential at is , with zero in its interior.
2. What projection does to a mean update
Let and , where or with equal probabilities. At , take a projected SGD step Compute and . Compare the expected iterate with the projected step that uses the exact gradient for .
Solution to exercise 2
At zero, has mean zero, and equals when and when . Thus . Since , the exact projected step stays at . Projection clips one of the two moves and leaves the other intact.
3. When two workers share a random seed
At a fixed , two workers run the same demand simulator to estimate a gradient. Each run returns , where or with equal probabilities. In one case the workers draw independently. In the other, they accidentally use the same random seed, so their draws coincide. Find the mean and variance of the average of the two gradients in each case. Briefly explain why the variances differ.
Solution to exercise 3
The independent average is , with mean and variance because the noises are independent. With a shared seed the average is , with mean and variance . Both workers contribute the same sample in that case, so the average has the variance of a single draw.
4. When all samples share a minimizer
Let , where or with equal probabilities. Starting at a fixed , run SGD with a fresh independent draw at each step and step size . Compute . Does the expected objective approach a positive noise floor, where ?
Solution to exercise 4
Since , the possible next iterates are and , each with probability . Thus . Here , so iterating expectations gives . Each sampled gradient vanishes at the common minimizer .
5. Same demands, different regret
A vendor chooses each day and pays . On day the vendor orders . On each later day the vendor orders the previous day’s demand, . Compute the vendor’s four-day regret for each demand sequence and , relative to the best fixed order on that sequence. Explain why the two regrets differ.
Solution to exercise 5
In either sequence each fixed order costs . The vendor pays each time the demand switches, and pays on the first day. The first sequence costs with regret . The second costs with regret . Both fixed-order costs depend only on demand counts, and the vendor’s costs depend on the order of arrival.
6. Two ways to report one iterate
Let be convex and let be the iterates from a run of SGD with . Given these iterates, draw uniformly from . Compare the conditional expected objective with the objective at the average . When can averaging be strictly better? Give a two-iterate example.
Solution to exercise 6
The conditional expectation is by uniform sampling. Jensen’s inequality bounds above by that average. Strict convexity on the segment between two distinct iterates gives strict inequality for . For example, at iterates and gives conditional expected objective for and objective for .
7. Shrink an estimate of the mean
Let be independent samples from a distribution with unknown mean and variance , with . Write and , so . You may use . For which does have smaller expected objective gap than ? Explain how the comparison fits the lecture’s sample lower bound, which concerns the worst case over distributions.
Solution to exercise 7
For the expected gap is . The estimator has mean and variance , so its expected gap is . It improves on exactly when . It loses for sufficiently large and its error grows without bound as grows, consistent with a lower bound on the worst-case error over the family.
Acceleration and momentum
8. An easy instance with a large condition number
Consider on , with condition number . You may choose a different positive step size at each update . Find two step sizes that reach the minimizer from every starting point in two gradient evaluations. Start by writing the update for each coordinate. How does the example fit the lecture’s lower bound for gradient methods?
Solution to exercise 8
The component multipliers of a step are and . Set to make the second coordinate zero, then set to make the first zero while preserving the second. The reverse order also works. The lower bound concerns a worst-case function in the smooth strongly convex class, in sufficiently large dimension. This particular quadratic has only two curvatures, both known.
9. Read the accelerated guarantee
For , valid smoothness and strong convexity constants are and . Run Nesterov’s method from with and . The first step gives . Find and and compare their objective values. Is the comparison consistent with the guarantee for a constant ?
Solution to exercise 9
The update is with . Thus and , then and . The objective rises from to . The guarantee bounds each gap by a decreasing envelope, which can accommodate this increase. Here in the lecture’s guarantee.
10. A momentum estimate after a large past gradient
At a step of SGD with momentum, condition on the current iterate and its history. The current true gradient is , and the fresh sampled gradient is or with equal probabilities. The previous momentum estimate is and the new estimate is . Which of and has lower conditional variance? Which has lower conditional mean squared error about ?
Solution to exercise 10
The sampled gradient has mean , variance , and mean squared error . The momentum estimate is or with equal probabilities. Its conditional mean is , its variance is , and its mean squared error about is . Momentum has less variance, and the fresh gradient has less squared error because it is unbiased.
Optional heavy-ball problems
11. Opposite signs at the ends of the spectrum
For heavy ball on a quadratic, the scalar error along an eigenvector of curvature satisfies . Take and . Compute the roots of for and . What do the moduli say about the geometric decay factors? Which mode has an alternating sign factor?
Solution to exercise 11
At the polynomial is , with repeated root . At it is , with repeated root . Both have geometric decay factor . The mode has an alternating factor . The repeated roots can also introduce a factor linear in .
12. Heavy ball and two-point cycles
Let be -smooth with . Run heavy ball with and , using the update Could the iterates alternate forever between two distinct points and ? Write the update at and at , then subtract the equations and use smoothness to justify your answer.
Solution to exercise 12
The update from to gives , and the update from to gives . Subtracting and applying smoothness gives Since and , the inequality is impossible.