1/25
Part 1 of 5 · Less varianceLearn

CUPED, from a pre-period to a smaller test

The sample-size lesson ended on a cost: detecting 10% going to 12% takes 3,839 users per arm, and the metric's variance sets that number. CUPED cuts it with data the test already has, each user's history from before it started. The 2013 paper that introduced it, by a team at Microsoft, reports for Bing: "we can reduce variance by about 50%, effectively achieving the same statistical power with only half of the users, or half the duration." Our version of the practice reads like this:

Each user has y, their metric during the test, and x, the same metric over the weeks before it. Write cuped(y, x): return the adjusted metric, which keeps the mean of y and has the least variance any adjustment y - theta * (x - mean(x)) can give, and the theta it used. Then read a test with it.

The practice comes in four levels. Level 1 writes cuped. Level 2 writes cuped_effect(y, x, t): the difference in adjusted means and its standard error, from one call on both arms. Level 3 keeps the users with no history, whose x is missing. Level 4 writes lin_effect, with one theta per arm.

You don't write it yet. The lesson starts with what less variance buys, finds the best θ, shows why the estimate stays unbiased, then runs CUPED on a test and answers the follow-ups. At the end you solve the whole problem, level by level, in an interview simulation with a 40-minute timer.

This lesson builds on the A/B test lesson's comparison of two means and on the sample-size formula, where the variance sits on top. The cluster-randomized lesson comes next, for tests where the unit you randomize isn't the unit you measure.