---
title: CUPED
description: "How Statsig Warehouse Native uses CUPED variance reduction to improve experiment sensitivity by adjusting for pre-experiment user behavior on metrics."
product: general
lang: en
token_estimate: 1104
---
# CUPED

CUPED (Controlled-experiment Using Pre-Existing Data) reduces a metric's variance by adjusting each user's metric value with the same metric measured before that user's exposure. Statsig defines this pre-exposure window per user, not as a fixed window before the experiment starts for all users. The adjustment increases confidence in experiment metrics and reduces pre-exposure bias, for example when groups were randomly different before you applied any treatment. Statsig applies CUPED automatically to Warehouse Native experiments.

> For AI agents: a documentation index is available at [/llms.txt](/llms.txt). Append `.md` to any page URL for markdown, or send `Accept: text/markdown`.

On Warehouse Native, you set the length of the pre-exposure window. Statsig recommends 7 days, the window Statsig Cloud always uses. For how CUPED fits with Statsig's other variance reduction options, refer to [Variance reduction](https://docs.statsig.com/statsig-warehouse-native/features/statistics/variance-reduction).

When a metric's own pre-exposure history isn't enough, such as in new-user experiments or for metrics that aren't autocorrelated, use [CURE](https://docs.statsig.com/statsig-warehouse-native/cure/introduction), which extends CUPED with additional covariates.

## CUPED for simple aggregations

The original [Microsoft paper](https://www.exp-platform.com/Documents/2013-02-CUPED-ImprovingSensitivityOfControlledExperiments.pdf) describes the methodology for simple aggregations, as does Statsig's [in-depth CUPED article](https://www.statsig.com/blog/cuped).

On Warehouse Native, units with no pre-exposure value for a metric keep their unadjusted values. Statsig doesn't reweight them, and leaving them unadjusted doesn't bias the result.

## CUPED for ratio metrics

The Microsoft paper also describes how to implement CUPED for metrics with a different analysis unit (Appendix B). Statsig extends this methodology to ratio metrics, where a numerator and a denominator represent each experiment unit. The variance reduction process finds the variance of the experiment data, the variance of the pre-exposure data, and the covariance between the two.

Denote the numerator, denominator, pre-exposure numerator, and pre-exposure denominator of a unit as $Y$, $N$, $X$, and $M$, respectively. Using the CUPED-reduced variance formula,

$$
Var(\frac{Y_{cv}}{N_{cv}})=Var(\frac{Y}{N})+\theta^2 Var(\frac{X}{M})-2\theta Cov(\frac{Y}{N}, \frac{X}{M})
$$

where Statsig finds optimal $\theta$ as

$$
\frac{Cov(\frac{Y}{N}, \frac{X}{M})}{Var(\frac{X}{M})}
$$

expanded to

$$
\frac{Cov(\frac{Y}{\mu_N}-\frac{\mu_Y N}{\mu^2_N}, \frac{X}{\mu_M}-\frac{\mu_X M}{\mu^2_M})}{Var(\frac{X}{\mu_M}-\frac{\mu_X M}{\mu^2_M})}
$$

This gives the following, where $\mathbb{E}[R]$ is the expected pre-exposure ratio $\mathbb{E}[\frac{X}{M}]$:

$$
\frac{\hat{Y_{c}}}{\hat{N_{c}}}=\frac{Y_{c}}{N_{c}}-\theta( \frac{X_{c}}{M_{c}} - \mathbb{E}[R])
$$

$$
\frac{\hat{Y_{t}}}{\hat{N_{t}}}=\frac{Y_{t}}{N_{t}}-\theta( \frac{X_{t}}{M_{t}} - \mathbb{E}[R])
$$

Because $\mathbb{E}[R]$ is hard to derive and the expectation term is the same for both groups, Statsig substitutes $\frac{X_{c}}{M_{c}}$ for $\mathbb{E}[R]$. This transforms the two formulas into the following:

$$
\frac{Y_{cv}(control)}{N_{cv}(control)}=\frac{Y(control)}{N(control)}
$$

$$
\frac{Y_{cv}(test)}{N_{cv}(test)}
:=\frac{Y(control)}{N(control)} - (\frac{Y(control)}{N(control)} - \theta \frac{X(control)}{M(control)}) + (\frac{Y(test)}{N(test)} - \theta\frac{X(test)}{M(test)})
=\frac{Y(test)}{N(test)} - \theta\frac{X(test)}{M(test)} + \theta \frac{X(control)}{M(control)}
$$

Using the optimal $\theta$, Statsig reduces group-level variance by applying the parameter to calculate the adjustment. An across-group $\theta$ doesn't necessarily reduce the variance for one group, or the sum of variances of all groups, but in most cases it does. Simulations show that 98.3% of metrics saw a decrease through CUPED.

Statsig applies the CUPED-reduced variance when all of the following are true:

- The core assumptions of the CUPED model hold. Rounding error or other data artifacts can violate them:

  - $E(\hat{X}) = E(X)$
  - The pooled variance of the adjusted population across groups is less than the variance of the unadjusted population.
- More than 100 units have pre-exposure values.
- More than 5% of units have pre-exposure values.

