In online A/B testing, CUPED reduces metric variance by replacing the outcome Y with Ycuped=Y−θ(X−E[X]), where X is a pre-experiment covariate unaffected by treatment. How do you show that E[Ycuped]=E[Y] (unbiasedness), derive the variance-minimising θ∗, and prove that the minimum variance is Var⁡(Y)(1−ρ2) where ρ=Corr⁡(X,Y)?

ML systems and evaluation, Online experiments
Level L3 Intermediate. Length Long. Nature Mat Mathematical.

What's being asked

Whether you can derive the CUPED estimator from first principles and understand its equivalence to OLS residualisation.

Key idea

Because X is measured before randomisation, E[X∣T=1]=E[X∣T=0]=E[X] (where T∈{0,1} is the treatment indicator), so subtracting θ(X−E[X]) leaves the average treatment effect untouched while removing the component of Y linearly explained by X.

Steps

  1. Prove unbiasedness: by linearity of expectation, E[Ycuped]=E[Y]−θ(E[X]−E[X])=E[Y]; because X is pre-treatment, E[X∣T=1]=E[X∣T=0], so E[Ycuped∣T=1]−E[Ycuped∣T=0]=E[Y∣T=1]−E[Y∣T=0].
  2. Write the variance as a quadratic in θ (using pooled data across both arms): Var⁡(Ycuped)=Var⁡(Y−θX)=Var⁡(Y)−2θCov⁡(X,Y)+θ2Var⁡(X).
  3. Differentiate with respect to θ and set to zero: ddθVar⁡(Ycuped)=−2Cov⁡(X,Y)+2θVar⁡(X)=0, yielding θ∗=Cov⁡(X,Y)Var⁡(X) (the second derivative 2Var⁡(X)>0 confirms a minimum).
  4. Substitute θ∗ back: Var⁡(Ycuped∗)=Var⁡(Y)−Cov⁡(X,Y)2Var⁡(X)=Var⁡(Y)(1−Cov⁡(X,Y)2Var⁡(X)Var⁡(Y))=Var⁡(Y)(1−ρ2).
  5. Interpret: if pre-experiment spend correlates with experiment spend at ρ=0.8, variance falls to 1−0.64=0.36 of its original value, cutting required sample size or test duration by nearly two-thirds (estimate θ∗ on pooled data to preserve unbiasedness).

Common mistakes

How long your answer should be

Half a page of clean algebra; 5–7 minutes.

Last checked on 4 December 2026.

Read this

Previous in ML systems and evaluation: What are the Shapley value formula and its four uniqueness axioms, and for a 3-feature model F={1,2,3} with coalition values v(∅)=10, v({1})=14, v({2})=12, v({3})=11, v({1,2})=20, v({1,3})=15, v({2,3})=13 and v({1,2,3})=25, what are the exact Shapley attributions ϕ1,ϕ2,ϕ3 (verifying efficiency)?
Next in ML systems and evaluation: Under covariate shift, how do you derive the importance-weighted loss Etest[ℓ]=Etrain[w(x) ℓ] and estimate w(x) using a domain classifier? Given ntrain=800 training points and ntest=200 unlabelled test points, four training examples receive calibrated domain probabilities P(test∣x)=[0.2,0.2,0.5,0.8] and per-example losses [0.1,0.2,0.3,0.8]: what are their importance weights, the weighted loss, and the ESS (effective sample size), and why does this fail under concept drift?