CUPED Effective Sample-Size Multiplier

Quick Overview

Implement a Python function that turns the correlation between a metric and a pre-experiment covariate into the CUPED effective sample-size multiplier. It tests how variance drives sample size, power and minimum detectable effect in A/B tests, and how to handle correlations near 1.

CUPED Effective Sample-Size Multiplier

Role: Data Scientist

Category: Analytics & Experimentation

Difficulty: easy

Interview Round: Other

CUPED adjusts an experiment metric with a pre-experiment covariate. When the covariate has correlation `rho` with the metric, the adjusted metric's variance is `1 - rho^2` times the original variance. Implement `effective_sample_size_multiplier(rho: float) -> float` in Python. It returns the effective sample-size multiplier `1 / (1 - rho^2)`. ```python effective_sample_size_multiplier(0.7) # -> 1.9607843137254901 (1 / 0.51) effective_sample_size_multiplier(0.5) # -> 1.3333333333333333 (1 / 0.75) effective_sample_size_multiplier(0.9) # -> 5.263157894736843 (1 / 0.19) ``` The last digit of a float can depend on how you compute `rho^2`, so compare results with a small tolerance. ```hint Link variance to sample size For a fixed effect size, significance level and power, how does the sample size a test needs depend on the metric's variance? ``` ### Constraints & Assumptions - `rho` is the correlation between the metric and the pre-experiment covariate, with `-1 < rho < 1`. - CUPED uses the variance-minimizing adjustment coefficient, so the remaining variance is exactly `1 - rho^2` of the original. ### What a Strong Answer Covers - Returns the reciprocal of the remaining-variance fraction and explains why required sample size scales with variance. - Keeps the multiplier separate from the variance saved (`rho^2`) and the variance remaining (`1 - rho^2`). - States the result at `rho = 0` and handles `|rho| >= 1`, where the formula divides by zero or turns negative. - Interprets the number in experiment terms, such as how many unadjusted users the adjusted analysis is worth. ### Follow-up Questions - Why is the multiplier `1 / (1 - rho^2)` and not the variance-reduction fraction `rho^2`? - What happens near `rho = 0` and near `rho = 1`? - At a fixed sample size with `rho = 0.7`, how much smaller is the minimum detectable effect? - If you adjust with several pre-experiment covariates in a regression, what takes the place of `rho^2`?

Overview: Implement a Python function that turns the correlation between a metric and a pre-experiment covariate into the CUPED effective sample-size multiplier. It tests how variance drives sample size, power and minimum detectable effect in A/B tests, and how to handle correlations near 1.

PracHub logo
General
Nov 25, 2026
easyData ScientistOtherAnalytics & Experimentation
0
0

CUPED adjusts an experiment metric with a pre-experiment covariate. When the covariate has correlation rho with the metric, the adjusted metric's variance is 1 - rho^2 times the original variance.

Implement effective_sample_size_multiplier(rho: float) -> float in Python. It returns the effective sample-size multiplier 1 / (1 - rho^2).

effective_sample_size_multiplier(0.7)  # -> 1.9607843137254901  (1 / 0.51)
effective_sample_size_multiplier(0.5)  # -> 1.3333333333333333  (1 / 0.75)
effective_sample_size_multiplier(0.9)  # -> 5.263157894736843   (1 / 0.19)

The last digit of a float can depend on how you compute rho^2, so compare results with a small tolerance.

Constraints & Assumptions

  • rho is the correlation between the metric and the pre-experiment covariate, with -1 < rho < 1 .
  • CUPED uses the variance-minimizing adjustment coefficient, so the remaining variance is exactly 1 - rho^2 of the original.

What a Strong Answer Covers Guidance

  • Returns the reciprocal of the remaining-variance fraction and explains why required sample size scales with variance.
  • Keeps the multiplier separate from the variance saved ( rho^2 ) and the variance remaining ( 1 - rho^2 ).
  • States the result at rho = 0 and handles |rho| >= 1 , where the formula divides by zero or turns negative.
  • Interprets the number in experiment terms, such as how many unadjusted users the adjusted analysis is worth.

Follow-up Questions Guidance

  • Why is the multiplier 1 / (1 - rho^2) and not the variance-reduction fraction rho^2 ?
  • What happens near rho = 0 and near rho = 1 ?
  • At a fixed sample size with rho = 0.7 , how much smaller is the minimum detectable effect?
  • If you adjust with several pre-experiment covariates in a regression, what takes the place of rho^2 ?