Skip to content

CUPED Variance Reduction in A/B Testing: Math, SQL and Failure Modes

Key Takeaways

  • CUPED is a linear adjustment that subtracts theta * (X - E[X]) from each user's metric Y, where X is a covariate the experiment treatment cannot affect (typically pre-exposure activity).
  • CUPED leaves 1 - r^2 of the raw metric variance, so its payoff depends on how strongly the pre-period covariate predicts the in-experiment metric.
  • Single-covariate CUPED uses one theta = Cov(Y, X) / Var(X) pooled across control and treatment; multi-covariate engines like Datadog pool a vector of theta_i coefficients across all variants with a small L2 penalty.
  • Keep new visitors who lack pre-period history in the CUPED sample. Statsig stratifies users by pre-exposure availability, and Datadog zero-fills alongside a missingness indicator covariate.
  • Ratio metrics like revenue per session need CUPED combined with the Delta Method (Appendix B of Deng et al. 2013) so user-level covariance between numerator and denominator stays intact.

How much traffic does CUPED save, and when is it worth building?

Updated

CUPED cuts required A/B test sample size by r^2, where r is the correlation between the in-experiment metric and a pre-experiment covariate X. Check r^2 before you write a single line of CUPED SQL. Alex Deng, Ya Xu, Ron Kohavi, and Toby Walker published CUPED (Controlled-Experiment Using Pre-Experiment Data) at Microsoft in 2013 to strip pre-existing user variance out of experiment metrics without biasing the lift estimate. When X is the same user's behavior before the test, remaining variance drops to 1 - r^2 of the raw metric variance.

The pre-post correlation r determines the CUPED payoff. On Microsoft Bing experiments, the paper's authors report that CUPED can "reduce variance by about 50%, effectively achieving the same statistical power with only half of the users, or half the duration". When pre-period and in-period revenue correlate at r = 0.70, variance falls 49% and you hit the same minimum detectable effect in half the traffic. On a cold landing page where visitors have zero prior history and you aren't adding assignment attributes (like country or browser), single-metric r is effectively zero, so CUPED adds engineering weight for nothing.

1 - r^2

remaining variance after optimal linear adjustment

49%

sample size saved when pre-post correlation r = 0.70

r >= 0.30

practical floor where CUPED saves at least 9% traffic

0%

prior-metric gain for new visitors without assignment attributes

The math and the correlation threshold

How much variance and runtime does CUPED save at each correlation r?

CUPED saves r^2 of the traffic, from 1% at r = 0.10 to 72.25% at r = 0.85, across common marketing correlation bands.

Required sample size scales linearly with metric variance, so the share of traffic CUPED saves equals r^2. Below r = 0.30 (under 9% savings), letting the test run one more day beats maintaining covariate pipelines.

Pre-post correlation (r)Variance reduction (r^2)Traffic needed vs raw t-testTypical marketing metric
0.10
1.0%
99.0% (skip CUPED)
Mixed cold-plus-returning landing page signup
0.30
9.0%
91.0% (marginal)
Infrequent high-AOV (average order value) ecommerce purchase
0.50
25.0%
75.0% (1.33x faster)
14-day repeat checkout revenue per active buyer
0.70
49.0%
51.0% (1.96x faster)
SaaS active days or repeat-purchase gross merchandise value (GMV)
0.85
72.25%
27.75% (3.60x faster)
High-frequency engagement, sessions, or ad impressions per user

Take a 4-week revenue test on returning buyers at r = 0.70: CUPED cuts runtime to roughly 14 days at the same statistical power. Because E[X - E[X]] = 0 under random assignment, Y_cuped keeps the exact same expected value as Y.

Which covariates and lookback windows should CUPED use?

CUPED covariates should start with the same metric from the pre-period, over a window matched to your product cadence, with extreme outliers capped.

CUPED lookback length trades history coverage against staleness, so Statsig, GrowthBook and Eppo ship different defaults. Statsig Cloud always uses a 7-day per-user pre-exposure window, while Statsig Warehouse Native lets you set any length. GrowthBook defaults to 14 days (configurable per organization or metric), and Eppo defaults to 30 days. Stretching past 60 days usually adds cold-start lag for newer accounts without lifting r.

Use the same metric from the pre-period first (pre-exposure revenue for experiment revenue). Deng et al. found that "using the same variable from the pre-experiment period as the covariate tends to give the best variance reduction"; on Bing, pre-period queries-per-user alone can reach a variance reduction rate of more than 45%. When a metric has no pre-period equivalent, such as first-time signup or retention, multi-covariate engines pull predictive signal from other historical metrics and pre-assignment attributes like country or browser. Eppo's CUPED++ does this across experiment metrics and assignment properties, while Statsig's CURE extends CUPED with extra covariates on Warehouse Native.

Revenue outliers distort the CUPED covariance term. Statsig applies Winsorization automatically on most metric types to cap extreme values at a percentile. In custom SQL, capping user revenue at the 99th or 99.5th percentile stops one $50,000 pre-period B2B order from distorting Cov(Y, X).

Production warehouse SQL for ratio metrics

How do you run CUPED plus the Delta Method in BigQuery or Snowflake SQL?

CUPED plus the Delta Method runs in BigQuery or Snowflake as one Winsorized numerator/denominator query for revenue per session, ending at z_stat.

Ratio metrics like Revenue per Session (SUM(revenue) / SUM(sessions)) break naive user-level t-tests because both numerator and denominator vary per user, and their covariance changes total variance. Statsig computes ratio-metric variances with the Delta Method and combines it with pre-post ratio covariance. The SQL below uses the simpler separate-component adjustment (similar to Datadog's numerator/denominator split) with 99th-percentile Winsorization so you can audit platform z-scores directly in SQL.

WITH exposures AS (
  -- Keep users exposed to exactly one variant and anchor to first exposure
  SELECT
    user_id,
    ANY_VALUE(variant) AS variant,
    MIN(exposed_at) AS first_exposed_at
  FROM analytics.experiment_exposures
  WHERE experiment_id = 'checkout_v4'
    AND exposed_at < TIMESTAMP '2026-11-15'
  GROUP BY user_id
  HAVING COUNT(DISTINCT variant) = 1
),
raw_metrics AS (
  -- Join against timestamped event-level logs (never daily-grain aggregates!)
  SELECT
    e.user_id,
    e.variant,
    COALESCE(SUM(CASE WHEN ev.event_at >= TIMESTAMP_SUB(e.first_exposed_at, INTERVAL 14 DAY)
                       AND ev.event_at < e.first_exposed_at THEN ev.revenue END), 0) AS y_pre_raw,
    COUNT(DISTINCT CASE WHEN ev.event_at >= TIMESTAMP_SUB(e.first_exposed_at, INTERVAL 14 DAY)
                         AND ev.event_at < e.first_exposed_at THEN ev.session_id END) AS x_pre,
    COALESCE(SUM(CASE WHEN ev.event_at >= e.first_exposed_at
                       AND ev.event_at < TIMESTAMP '2026-11-15' THEN ev.revenue END), 0) AS y_exp_raw,
    COUNT(DISTINCT CASE WHEN ev.event_at >= e.first_exposed_at
                         AND ev.event_at < TIMESTAMP '2026-11-15' THEN ev.session_id END) AS x_exp
  FROM exposures e
  LEFT JOIN analytics.user_events ev
    ON e.user_id = ev.user_id
  GROUP BY 1, 2
),
caps AS (
  -- 99th-percentile revenue Winsorization across pooled arms
  SELECT
    APPROX_QUANTILES(y_pre_raw, 100)[OFFSET(99)] AS p99_pre,
    APPROX_QUANTILES(y_exp_raw, 100)[OFFSET(99)] AS p99_exp
  FROM raw_metrics
),
user_metrics AS (
  SELECT
    m.user_id,
    m.variant,
    LEAST(m.y_pre_raw, c.p99_pre) AS y_pre,
    CAST(m.x_pre AS FLOAT64) AS x_pre,
    LEAST(m.y_exp_raw, c.p99_exp) AS y_exp,
    CAST(m.x_exp AS FLOAT64) AS x_exp
  FROM raw_metrics m
  CROSS JOIN caps c
),
pooled_theta AS (
  SELECT
    COALESCE(COVAR_POP(y_exp, y_pre) / NULLIF(VAR_POP(y_pre), 0), 0) AS theta_y,
    COALESCE(COVAR_POP(x_exp, x_pre) / NULLIF(VAR_POP(x_pre), 0), 0) AS theta_x,
    AVG(y_pre) AS mu_y_pre,
    AVG(x_pre) AS mu_x_pre
  FROM user_metrics
),
adjusted AS (
  SELECT
    m.user_id,
    m.variant,
    m.y_exp - p.theta_y * (m.y_pre - p.mu_y_pre) AS y_adj,
    m.x_exp - p.theta_x * (m.x_pre - p.mu_x_pre) AS x_adj
  FROM user_metrics m
  CROSS JOIN pooled_theta p
),
arm_stats AS (
  SELECT
    variant,
    COUNT(*) AS n,
    AVG(y_adj) / NULLIF(AVG(x_adj), 0) AS cuped_ratio,
    SQRT(
      GREATEST(0,
        (VAR_SAMP(y_adj) / COUNT(*))
        + POW(AVG(y_adj) / NULLIF(AVG(x_adj), 0), 2) * (VAR_SAMP(x_adj) / COUNT(*))
        - 2 * (AVG(y_adj) / NULLIF(AVG(x_adj), 0)) * (COVAR_SAMP(y_adj, x_adj) / COUNT(*))
      ) / POW(NULLIF(AVG(x_adj), 0), 2)
    ) AS delta_se
  FROM adjusted
  GROUP BY variant
)
SELECT
  t.cuped_ratio - c.cuped_ratio AS abs_lift,
  SQRT(POW(t.delta_se, 2) + POW(c.delta_se, 2)) AS diff_se,
  (t.cuped_ratio - c.cuped_ratio)
    / NULLIF(SQRT(POW(t.delta_se, 2) + POW(c.delta_se, 2)), 0) AS z_stat
FROM arm_stats t
JOIN arm_stats c
  ON t.variant = 'treatment' AND c.variant = 'control';

Run this in BigQuery (for Snowflake, swap TIMESTAMP_SUB(..., INTERVAL 14 DAY) for DATEADD(day, -14, e.first_exposed_at), APPROX_QUANTILES(...)[OFFSET(99)] for APPROX_PERCENTILE(..., 0.99), and FLOAT64 for FLOAT). At two-sided alpha = 0.05, |z_stat| >= 1.96. Because COALESCE(..., 0) is unstratified zero-fill, it stays unbiased under random assignment; if most visitors are first-time users, stratify or add a missingness indicator as shown below.

How should CUPED handle new users with no pre-experiment history?

CUPED keeps new users with no pre-experiment history in the sample, stratified or flagged with a missingness indicator so they don't distort covariate slopes.

Marketing sites mix returning customers with brand-new visitors who have no CUPED covariate. Dropping missing rows biases your population, while naive zero-filling lets missing users distort the CUPED adjustment slope theta.

Method for missing pre-period dataHow it behavesWhen to use it
Drop users with no history
Shrinks the test population to returning users and hides new-user regressions
Never do this
Replace NULL with 0 in one unstratified query
Stays unbiased under random assignment, though high new-user share dilutes theta
Quick SQL sanity check
Zero-fill plus a missingness indicator covariate
Sets missing pre-exposure aggregations to 0 and adds a separate missingness indicator so imputed zeros don't distort adjustment
Multi-covariate regression pipelines
Stratify by pre-period availability and aggregate
Groups users into strata by pre-exposure data availability, estimates variant effects per stratum, then combines them
Default for mixed new/returning traffic

Six failure modes that break CUPED

Which leakage and estimation bugs corrupt CUPED lifts?

Three bugs corrupt CUPED lifts: global-date lookbacks, unregularized per-arm slopes, and post-assignment covariates.

  • Global-date CUPED lookbacks leak post-exposure events whenever a rollout ramps in stages. Statsig defines its 7-day window per user instead of using one global launch date; keep your SQL filtered strictly below each user's first_exposed_at.
  • Unregularized per-arm theta slopes inflate variance on small samples. Standard CUPED pools variants into one shared adjustment (platforms like Eppo fit per-arm models only with L2 ridge regularization to stabilize slopes).
  • Post-assignment covariates bias the CUPED lift estimate whenever the treatment changes the covariate itself. Device type works if logged at assignment, whereas logged-in status leaks treatment behavior if the variant pushes logins.

How do peeking, Sample Ratio Mismatch (SRM) and heavy tails break CUPED?

Peeking, Sample Ratio Mismatch (SRM) and heavy tails break CUPED because CUPED narrows intervals but does not control peeking, fix a broken split, or tame revenue whales.

  • Tighter intervals tempt teams to call winners on day 3. CUPED doesn't control peeking; pair it with sequential testing or a fixed sample horizon.
  • A broken split (like 51.2% / 48.8% across 50,000 users, chi-square = 28.8) creates pre-period imbalance that CUPED can't fix. Run an SRM check before trusting any adjusted lift.
  • One extreme revenue whale can dominate Cov(Y, X) and widen intervals instead of shrinking them. Apply percentile Winsorization to cap outliers.

Platform support compared

How do Statsig, GrowthBook, Eppo and Datadog implement CUPED?

Statsig, GrowthBook, Eppo and Datadog implement CUPED with different lookback rules, missing-data handling, and ratio variance; compare them before enabling the toggle.

PlatformVariance reduction methodMissing pre-period handlingRatio metrics
CUPED with fixed 7-day per-user lookback on Cloud (configurable on Warehouse Native) plus automatic Winsorization; CURE adds extra covariates
Stratifies users by pre-exposure data availability
Delta Method plus pre-post ratio covariance
GrowthBook
CUPEDps combining pooled CUPED with post-stratification across user dimensions (14-day default lookback, configurable)
Notes lower power for new users; recommends disabling CUPEDps on metrics that never collect pre-exposure values
Delta Method in SQL
Eppo
CUPED++ multi-covariate ridge regression per variation (30-day default lookback + assignment properties)
Uses assignment properties (country, browser) when prior metric data is absent
Warehouse ratio adjustment
Datadog
Pooled multi-covariate CUPED with small L2 penalty across pre-exposure metrics and top 10 property values per variant
Zero-fills missing pre-exposure aggregations and adds a separate missingness indicator covariate
Splits ratio metrics into separate numerator and denominator covariates

Common Questions

Why did my CUPED point estimate shift slightly from the raw difference in means?

The CUPED point estimate shifts because finite samples almost always start with a tiny random pre-period imbalance (mean(X_t) != mean(X_c)). Subtracting theta * (X - E[X]) removes that chance imbalance, moving the estimate closer to the true lift while staying unbiased in expectation. Large shifts across multiple tests point to covariate leakage or an SRM.

Can I use CUPED when 80% of my traffic is first-time visitors?

CUPED works when 80% of traffic is first-time visitors, as long as you stratify returning and new users or add a missingness indicator instead of dropping new visitors. Total CUPED variance savings stay in the single digits unless you also feed pre-assignment attributes like country or browser.

Does CUPED help on binary conversion or retention metrics?

Single-metric CUPED won't help on one-time signup conversion because users who already signed up can't enter a new-user signup test. Eppo specifically notes that conversion and retention metrics lack a direct pre-experiment analog, so CUPED++ borrows predictive signal from other historical metrics and assignment properties instead.

Does CUPED work with sequential testing?

CUPED works with sequential testing when you adjust before you test. Compute the variance-reduced per-user observation Y_adj (or linearized ratio) first. Then pass the adjusted mean and standard error into your sequential boundary (such as a modified Sequential Probability Ratio Test, mSPRT, or group sequential alpha spending). CUPED narrows standard errors at each check; sequential boundaries control false positives across repeated checks.