When a product introduces a new recommendation algorithm, ranking rule, or entry point, an A/B experiment usually evaluates its effect. A subset of users is randomly selected and then randomly assigned: one group uses the old version, the other the new version. After some time, metrics such as DAU, time per user, or click-through rate are compared. The observed difference contains both the version effect and random variation, so the higher metric alone does not establish an effect.

Interpreting the result requires answering both a causal and a statistical question. The causal question is whether the new version caused the change, rather than user composition or other factors. The statistical question is how much uncertainty random variation introduces into the effect estimate. Random assignment mainly makes the groups comparable; statistical inference quantifies the estimate’s uncertainty.

This post uses the potential outcomes framework (Rubin Causal Model) to define the causal effect of interest, then shows why the difference between group means estimates it under random assignment. It next explains how hypothesis testing assesses uncertainty through p-values, confidence intervals, statistical power, and sample size. Finally, it examines changes in assignment ratios, stopping when an interim result becomes significant, and mismatches in data granularity.

1. From Population Measurements to Sample-Based Inference

Statistical inference uses samples to estimate population characteristics. Recording every person in a population, as in a census, gives population statistics directly. Observing only some people requires inference from a sample. How well the sample represents the target population determines whom the conclusions can generalize to. Random assignment improves comparability between treatment and control but does not automatically make the experimental sample representative of all users.

A/B experiments follow the basic idea of a randomized controlled trial (RCT): medical trials compare treatment and control, while online experiments compare new and old versions. For example, 5% of users receive a new algorithm and 95% receive the old one; time per user is compared after a week. The experiment first estimates the version effect among participating users, then assesses generalization based on how the sample relates to the target population.

Suppose time per user is 1.2% higher in treatment. We want to know how much the metric would change if the same users all received the new version rather than all receiving the old one. But each user can receive only one version in a given experiment. The outcome under the other version cannot be observed simultaneously: this is the counterfactual problem.

2. The Potential Outcomes Framework

2.1 Assignment and Potential Outcomes

Neyman first proposed the potential outcomes framework in 1923. Suppose the experiment contains nn units; in a user experiment, each unit is a user. Let ZiZ_i denote user ii‘s assignment: 1 for treatment and 0 for control. Each user has a potential outcome under each version:

  • Yi(1)Y_i(1): user ii‘s metric under the new version.
  • Yi(0)Y_i(0): user ii‘s metric under the old version.

These are called potential outcomes. For example, Yi(1)Y_i(1) is dwell time under the new version and Yi(0)Y_i(0) is dwell time under the old version. We observe the outcome for the group to which the user is assigned, so the observed value is:

Yiobs=Zi⋅Yi(1)+(1−Zi)⋅Yi(0).Y_i^{\text{obs}} = Z_i \cdot Y_i(1) + (1 - Z_i) \cdot Y_i(0).

2.2 Individual Effects and Counterfactuals

An individual causal effect is the difference between the same user’s outcomes under the new and old versions:

τi:=Yi(1)−Yi(0).\tau_i := Y_i(1) - Y_i(0).

If the new version increases a user’s dwell time, τi\tau_i is positive; if it decreases dwell time, the effect is negative. The difficulty is that only one outcome is observed; the other is a counterfactual. One experiment cannot directly measure the individual causal effect for the same user, because the outcome under the other version is missing.

2.3 SUTVA: Outcomes Depend on the Unit’s Own Treatment

The notation above describes a user’s treatment with one assignment variable, ZiZ_i. For two potential outcomes to describe the experiment adequately, other users’ assignments must not affect the user’s outcome, and each treatment must be well defined. These conditions form the Stable Unit Treatment Value Assumption (SUTVA), systematized by Rubin:

  • No interference requires user ii‘s outcome to depend only on their own assignment. If a treatment user shares content recommended by the new algorithm with a friend in control and changes the friend’s metric, this violates no interference.
  • Treatment variation irrelevance requires a clear treatment behind each assignment label. If treatment users in different regions actually receive versions A and B, the label “new version” alone cannot describe the treatment accurately.

Social sharing, recommendations, and two-sided markets can create interference between users. These settings can use cluster randomization or switchback designs, where the same unit alternates treatments across time periods, to define comparable experimental units. This post considers randomized controlled experiments satisfying the basic conditions above.

2.4 Average Treatment Effect

Although individual effects cannot be measured directly, rollout decisions usually concern the overall change. The Average Treatment Effect (ATE) averages the individual effects across all participating units:

τ:=1n∑i=1n(Yi(1)−Yi(0))=Yˉ(1)−Yˉ(0).\tau := \frac{1}{n} \sum_{i=1}^{n} \big(Y_i(1) - Y_i(0)\big) = \bar{Y}(1) - \bar{Y}(0).

Yˉ(1)\bar{Y}(1) is the mean metric if all these users receive the new version; Yˉ(0)\bar{Y}(0) is the mean if they all receive the old version. Both states cannot be observed simultaneously, but random assignment lets the observed group means estimate these potential means, and their difference estimate the ATE.

3. Randomization and the Difference-in-Means Estimator

3.1 Why Random Assignment Estimates the Average Effect

In Neyman’s approach, each user’s potential outcomes under both versions are fixed, and assignment is random. When every user has the same chance of entering treatment, both groups represent the same experimental users on average. Any one assignment still produces random differences, but neither group is systematically favored.

The observed treatment mean can therefore estimate the mean if all users receive the new version, and the control mean can estimate the mean if all receive the old version. Randomization makes the groups comparable; it does not make outcomes under the two versions equal. If the new version has an effect, the observed outcomes should differ.

3.2 The Difference-in-Means Estimator

Let treatment contain n1n_1 users and control n0n_0 users, totaling nn. Subtracting the control mean from the treatment mean gives an estimator of the average effect:

τ^:=1n1∑Zi=1Yiobs−1n0∑Zi=0Yiobs.\hat{\tau} := \frac{1}{n_1} \sum_{Z_i = 1} Y_i^{\text{obs}} - \frac{1}{n_0} \sum_{Z_i = 0} Y_i^{\text{obs}}.

This is the difference-in-means estimator. Whether it has a causal interpretation depends on the assignment design. Similar group sizes, ages, or historical metrics alone do not provide the same guarantee as random assignment.

3.3 Why Difference in Means Is Unbiased

Assignment indicators let us rewrite each within-group sum as a sum over all users. Treatment users have Zi=1Z_i = 1 and the others 0; control membership is represented by 1−Zi1-Z_i:

τ^=1n1∑i=1nZi Yi(1)−1n0∑i=1n(1−Zi) Yi(0).\hat{\tau} = \frac{1}{n_1} \sum_{i=1}^{n} Z_i \, Y_i(1) - \frac{1}{n_0} \sum_{i=1}^{n} (1 - Z_i) \, Y_i(0).

Here we consider random assignment with fixed group sizes: n1n_1 and n0n_0 are set by the design, and each user’s probability of entering treatment is n1/nn_1/n. When taking expectations, potential outcomes stay fixed; we average only over assignment ZiZ_i. Thus, E[Zi]\mathbb{E}[Z_i] can be replaced by n1/nn_1/n:

E[τ^]=1n1∑i=1nE[Zi]⋅Yi(1)−1n0∑i=1n(1−E[Zi])⋅Yi(0)=1n1∑i=1nn1n Yi(1)−1n0∑i=1nn0n Yi(0)=1n∑i=1nYi(1)−1n∑i=1nYi(0)=Yˉ(1)−Yˉ(0)=τ.\begin{aligned} \mathbb{E}[\hat{\tau}] &= \frac{1}{n_1} \sum_{i=1}^{n} \mathbb{E}[Z_i] \cdot Y_i(1) - \frac{1}{n_0} \sum_{i=1}^{n} \big(1 - \mathbb{E}[Z_i]\big) \cdot Y_i(0) \\ &= \frac{1}{n_1} \sum_{i=1}^{n} \frac{n_1}{n} \, Y_i(1) - \frac{1}{n_0} \sum_{i=1}^{n} \frac{n_0}{n} \, Y_i(0) \\ &= \frac{1}{n} \sum_{i=1}^{n} Y_i(1) - \frac{1}{n} \sum_{i=1}^{n} Y_i(0) \\ &= \bar{Y}(1) - \bar{Y}(0) \\ &= \tau. \end{aligned}

The result is E[τ^]=τ\mathbb{E}[\hat{\tau}] = \tau. This is what “unbiased” means: over repeated random assignments of the same users, the average estimate equals the true average effect. It does not guarantee the true value in any one experiment. The key condition used here is E[Zi]=n1/n\mathbb{E}[Z_i] = n_1/n for every user.

3.4 Changes in Assignment Ratios and Bias in Cumulative Means

Suppose control and treatment each receive 1% of users on day one. On day two, control stays at 1% while treatment rises to 5%. Later entrants then make up a larger share of treatment. If the metric also changes over time, the cumulative difference includes both the version effect and the groups’ different time composition, producing bias resembling Simpson’s paradox.

Increasing both groups from 1%/1% to 5%/5% is different. Among experimental participants, the treatment-to-control ratio stays at 1:1. Earlier entrants have longer exposure, but that difference is symmetric across groups. A fixed relative assignment ratio avoids the between-group bias introduced by an asymmetric ramp; the estimate still corresponds to the actual participants and observation period.

Known assignment probabilities allow inverse probability weighting to correct the estimate, as shown in Appendix B. But keeping the relative treatment-to-control ratio fixed throughout the experiment is more reliable. When increasing total traffic, expand both groups proportionally.

4. Hypothesis Testing: From Estimator to Decision

4.1 Null and Alternative Hypotheses, Type I and II Errors

Unbiasedness means no systematic bias on average, but finite samples still contain random variation. Even if the true average effect is zero, the observed τ^\hat{\tau} will usually be nonzero. Hypothesis testing asks how unusual the observed difference would be if the true average effect were zero.

We use a two-sided test, allowing the new version to cause either a positive or a negative change:

  • Null hypothesis H0H_0: τ=0\tau = 0, so the new version’s average effect is zero.
  • Alternative hypothesis H1H_1: τ≠0\tau \neq 0, so its average effect is nonzero.

Decisions based on samples can be wrong in two ways:

  • Type I error (false positive): rejecting H0H_0 and concluding that an effect exists when the average effect is actually zero. The significance level α\alpha, commonly set to 5%, controls this error.
  • Type II error (false negative): failing to reject H0H_0 when a particular average effect exists. Its probability is β\beta, and the probability of detecting that effect, 1−β1-\beta, is called statistical power.

The test assumes H0H_0 and evaluates whether the difference is too extreme. It rejects H0H_0 when the difference crosses the predefined threshold; otherwise, uncertainty remains. Failing to reject the null does not prove that the new version has no effect.

4.2 The Central Limit Theorem

To judge whether a difference is extreme, we need to know how the difference in means varies under repeated sampling. The Central Limit Theorem (CLT) approximates the distribution of means for large samples.

The classical Lindeberg–Lévy form requires independent, identically distributed samples with finite, strictly positive variance. Let X1,X2,…,XnX_1, X_2, \ldots, X_n have mean μ\mu and variance σ2\sigma^2. As the sample grows, the sample mean minus the true mean, divided by its standard deviation, converges in distribution to the standard normal:

n (Xˉn−μ)σ  →d  N(0,1),\frac{\sqrt{n}\,(\bar{X}_n - \mu)}{\sigma} \;\xrightarrow{d}\; N(0, 1),

The symbol →d\xrightarrow{d} means convergence in distribution: the distribution of the standardized variable approaches the standard normal on the right.

Characteristic functions explain why. Define Yi:=Xi−μY_i := X_i - \mu, with mean zero and variance σ2\sigma^2. Its characteristic function is ϕY(t):=E[eitY]\phi_Y(t) := \mathbb{E}[e^{i t Y}], describing the distribution of the random variable YY. A finite second moment gives the following expansion near t=0t=0:

ϕY(t)=1−σ2t22+o(t2),t→0.\phi_Y(t) = 1 - \frac{\sigma^2 t^2}{2} + o(t^2), \qquad t \to 0.

Sum and standardize these variables, defining Sn:=1σn∑i=1nYiS_n := \frac{1}{\sigma \sqrt{n}} \sum_{i=1}^{n} Y_i. Independence makes the sum’s characteristic function the product of the individual characteristic functions:

ϕSn(t)=∏i=1nE ⁣[exp⁡ ⁣(itYiσn)]=[ϕY ⁣(tσn)]n=[1−t22n+o ⁣(1n)]n  →n→∞  e−t2/2.\begin{aligned} \phi_{S_n}(t) &= \prod_{i=1}^{n} \mathbb{E}\!\left[\exp\!\left(\frac{i t Y_i}{\sigma \sqrt{n}}\right)\right] = \left[\phi_Y\!\left(\frac{t}{\sigma \sqrt{n}}\right)\right]^n \\ &= \left[1 - \frac{t^2}{2 n} + o\!\left(\frac{1}{n}\right)\right]^n \;\xrightarrow{n \to \infty}\; e^{-t^2 / 2}. \end{aligned}

The limit e−t2/2e^{-t^2/2} is exactly the characteristic function of a standard normal distribution. By Lévy’s continuity theorem, SnS_n converges in distribution to N(0,1)N(0,1); Appendix A gives the detailed steps. The original metric need not be normally distributed. Under these conditions, the sample mean’s random variation approaches a normal distribution.

4.3 Applying the Test to A/B Experiments

Apply this result to two experimental groups. The following uses a population model with two independent samples as a large-sample approximation; under the fixed finite-population randomization analysis used earlier, the variance would also reflect heterogeneity in individual effects. Assume independent, identically distributed observations within each group, finite variances, independence between groups, and sufficiently large samples. The difference in means is approximately normal, with variance equal to the sum of the two means’ variances:

Xˉ1−Xˉ0  ≈d  N ⁣(μ1−μ0,  σ12n1+σ02n0).\bar{X}_1 - \bar{X}_0 \;\overset{d}{\approx}\; N\!\left(\mu_1 - \mu_0,\;\frac{\sigma_1^2}{n_1} + \frac{\sigma_0^2}{n_0}\right).

Estimate population variances with sample variances. The denominator below is the standard error of the difference in means. The statistic TT expresses the observed difference in units of standard error:

T:=Xˉ1−Xˉ0σ^02/n0+σ^12/n1.T := \frac{\bar{X}_1 - \bar{X}_0}{\sqrt{\hat{\sigma}_0^2 / n_0 + \hat{\sigma}_1^2 / n_1}}.

Under H0H_0, TT is approximately N(0,1)N(0,1). At significance level α\alpha, the two-sided test rejects H0H_0 when ∣T∣>z1−α/2|T| > z_{1-\alpha/2}, where zqz_q is the standard normal’s qq quantile. The larger the difference relative to its standard error, the harder it is to explain by random variation under a zero effect.

4.4 The p-Value

A p-value expresses this judgment as a probability: assuming H0H_0, how likely is a test statistic at least as extreme as the observed one? Under the two-sided normal approximation:

p=2⋅(1−Φ(∣T∣)),p = 2 \cdot \big(1 - \Phi(|T|)\big),

Φ\Phi is the standard normal cumulative distribution function. A smaller p-value means the observed difference is rarer under the null. It describes a probability of data conditional on the null hypothesis, rather than the probability that a hypothesis is true.

For example, p<0.05p<0.05 does not mean there is more than a 95% chance that the new version is effective. Computing a hypothesis’s posterior probability requires Bayesian inference and information such as a prior. The American Statistical Association’s 2016 statement on p-values discusses these misinterpretations. A p-value alone also cannot establish whether an effect justifies rollout; effect size and business value need separate assessment.

4.5 Confidence Intervals

While a p-value focuses on rejecting the null, a confidence interval shows both an effect estimate and its uncertainty range. Under the normal approximation above, a 1−α1-\alpha confidence interval for τ\tau is:

τ^±z1−α/2⋅σ^02/n0+σ^12/n1.\hat{\tau} \pm z_{1 - \alpha/2} \cdot \sqrt{\hat{\sigma}_0^2 / n_0 + \hat{\sigma}_1^2 / n_1}.

A confidence interval has a coverage rate that describes its construction method. For 95% coverage, repeating the same experimental design and constructing an interval by this formula each time would produce intervals covering the true effect about 95% of the time. The 95% refers to coverage over repeated experiments, rather than the probability that the true parameter lies in this particular interval. In the frequentist framework, the parameter is fixed and the interval varies with sampling.

4.6 Statistical Power and Sample Size

Statistical power measures an experiment’s ability to detect a particular true effect. It depends on effect size Δ=μ1−μ0\Delta = \mu_1-\mu_0, sample size, and metric variance. Smaller effects or greater variation usually require more observations. Assuming equal group variances and nn observations per group, two-sided test power can be approximated by:

1−β≈1−Φ ⁣(z1−α/2−∣Δ∣2σ2/n).1 - \beta \approx 1 - \Phi\!\left(z_{1 - \alpha/2} - \frac{|\Delta|}{\sqrt{2 \sigma^2 / n}}\right).

For a specified effect and target power, solve for the required sample size per group:

n=2(σ⋅(z1−α/2−zβ)Δ)2.n = 2 \left(\frac{\sigma \cdot (z_{1 - \alpha/2} - z_\beta)}{\Delta}\right)^2.

Here, nn is the sample size per group and zβz_\beta is the standard normal’s β\beta quantile. Choose the effect size, significance level, and target power before the experiment and use them to plan sample size. With a fixed-sample test, an interim significant result does not justify ending early.

5. Early Stopping and Data Granularity

5.1 Fixed-Sample Tests and Interim Monitoring

Traditional fixed-sample t-tests and z-tests evaluate results at a predefined sample size or endpoint. In practice, dashboards refresh daily, and teams check p-values each day: stop if significant, continue otherwise. This is called peeking. It chooses the stopping time from interim results, changing the original testing rule.

Checking once a day for 14 days creates 14 opportunities to find significance. Even with a 5% threshold at each check, the probability of at least one false positive over the experiment exceeds the single-test rate of 5%. In simulations reported by Johari et al. in Peeking at A/B Tests (KDD 2017), continuous monitoring with result-dependent stopping pushed the classical t-test’s actual false-positive rate above 30%; the exact size depends on how often results are checked and how long the experiment runs.

This stopping rule preferentially selects random fluctuations that are large in absolute value; stopping only on positive significance, or reporting only positive results, selects random peaks. Suppose 100 experiments in a year repeatedly report “a significant 1% improvement” but produce no cumulative growth in the overall metric. Some reported gains will be random peaks selected by early stopping. Such improvements fail to reproduce consistently later.

When an experiment needs to end based on interim results, use sequential testing. Wald’s SPRT uses a likelihood ratio and upper and lower thresholds A,BA, B to decide when to stop. mSPRT (Always Valid Inference, Johari et al. 2015) uses a mixture prior to construct inference that can be checked at any time. Sequential tests incorporate monitoring and stopping rules into the design, controlling the Type I error rate across the process. At the same sample size, their power at a given analysis is usually lower than that of a fixed-sample t-test.

Sequential testing addresses peeking but does not automatically remove sample dependence. The basic SPRT and mSPRT derivations above rely on an independent, identically distributed sample sequence. Records from the same user across batches are correlated, and behavior differs between weekdays and weekends. Data processing and variance estimation must still address these issues.

5.2 Randomizing Users but Treating Their Records as Independent

The CLT and mean-variance formulas above use the independent, identically distributed assumption. In online experiments, users are usually the assignment units, while logs may record impressions, clicks, or plays. Multiple records from one user cannot simply be treated as independent samples; doing so overstates the effective sample size.

For example, an experiment assigns users while logging each (user, video) impression and click. A user’s activity level and propensity to click affect all of their repeated actions, creating within-user correlation. Let user ii have nin_i records, assume independence between users, and allow dependence within a user. The sum’s variance includes both individual record variances and within-user covariances:

Var ⁣(∑i,jXij)=∑iVar ⁣(∑jXij)=∑i ⁣[∑jVar(Xij)+∑j≠kCov(Xij,Xik)].\begin{aligned} \mathrm{Var}\!\left(\sum_{i, j} X_{ij}\right) &= \sum_i \mathrm{Var}\!\left(\sum_j X_{ij}\right) \\ &= \sum_i \!\left[\sum_j \mathrm{Var}(X_{ij}) + \sum_{j \neq k} \mathrm{Cov}(X_{ij}, X_{ik})\right]. \end{aligned}

When records from the same user have positive covariance, omitting these terms understates the true variance. Underestimating variance understates the standard error, making a difference appear more significant than it is: the test statistic’s absolute value is too large, the p-value too small, and the false-positive rate rises.

For user-level mean metrics, aggregate each user’s records into one observation before testing user-level samples. Data processing must match both the assignment unit and the target metric. If the original metric is a mean per impression, replacing it with a mean per user changes the metric’s meaning; choose a variance estimator appropriate to the original metric. Aggregation across days or keys also adds data-processing costs.

6. Wrapping Up

A/B experiments use sample differences between groups to estimate version effects. Potential outcomes define the causal quantity of interest, random assignment makes the difference in means an unbiased estimator, and variance estimation and hypothesis testing quantify the uncertainty of this estimate. Conclusions first apply to participating users; generalization depends on how the experimental sample relates to the target population.

Assignment ratios, data granularity, and stopping rules directly affect this inference. An asymmetric ramp changes the groups’ time composition; treating repeated user logs as independent understates variance; stopping on significance increases the false-positive rate of a fixed-sample test. Results must therefore be interpreted in light of both the experimental design and the statistical methods, rather than the dashboard’s p-value alone.

Building on these foundations, CUPED (Deng et al., WSDM 2013) uses pre-experiment information to reduce variance and improve detection at the same sample size. Cluster randomization and switchback designs adjust randomization units to address interference between users. These methods improve statistical efficiency and experimental design, respectively, while preserving a clear causal question and control of error rates.

Appendix A: A Full Proof of the CLT

This appendix supplies three steps in the characteristic-function argument: defining the remainder, computing the limit, and connecting characteristic-function convergence to convergence in distribution.

(1) The remainder o(t2)o(t^2). This notation means that the remainder becomes small relative to t2t^2 as tt approaches zero. A function ϵ(t)\epsilon(t) tending to zero makes this explicit:

ϕY(t)=1−σ2t22+t2⋅ϵ(t),ϵ(t)→0 as t→0.\phi_Y(t) = 1 - \frac{\sigma^2 t^2}{2} + t^2 \cdot \epsilon(t), \qquad \epsilon(t) \to 0 \text{ as } t \to 0.

This follows from the characteristic function’s second-order expansion near zero. A zero mean eliminates the first-order term, while the variance determines the second-order term: ϕY′(0)=iE[Y]=0\phi_Y'(0)=i\mathbb{E}[Y]=0 and ϕY′′(0)=−E[Y2]=−σ2\phi_Y''(0)=-\mathbb{E}[Y^2]=-\sigma^2. A finite second moment guarantees the derivatives and expansion needed here.

(2) The limit of the characteristic-function product. For fixed tt, taking the logarithm of ϕY(t/(σn))n\phi_Y(t/(\sigma\sqrt{n}))^n converts the nnth power into multiplication by nn:

ϕY ⁣(tσn)=1−t22n+t2σ2n⋅ϵ ⁣(tσn),n⋅ln⁡ϕY ⁣(tσn)=n⋅[−t22n+o ⁣(1n)]=−t22+o(1).\begin{aligned} \phi_Y\!\left(\frac{t}{\sigma \sqrt{n}}\right) &= 1 - \frac{t^2}{2 n} + \frac{t^2}{\sigma^2 n} \cdot \epsilon\!\left(\frac{t}{\sigma \sqrt{n}}\right), \\ n \cdot \ln \phi_Y\!\left(\frac{t}{\sigma \sqrt{n}}\right) &= n \cdot \left[ -\frac{t^2}{2 n} + o\!\left(\frac{1}{n}\right) \right] = -\frac{t^2}{2} + o(1). \end{aligned}

The second step uses ln⁡(1+x)=x+O(x2)\ln(1+x)=x+O(x^2) and the fact that ϵ(t/(σn))\epsilon(t/(\sigma\sqrt{n})) tends to zero. Exponentiating gives ϕSn(t)→e−t2/2\phi_{S_n}(t)\to e^{-t^2/2}. The limiting function is the standard normal’s characteristic function.

(3) From characteristic functions to distributions. Lévy’s continuity theorem states that if characteristic functions converge pointwise and the limit is continuous at zero, the corresponding distributions converge to the distribution described by that limit. Here, e−t2/2e^{-t^2/2} is continuous at zero, giving Sn→dN(0,1)S_n\xrightarrow{d}N(0,1).

Other versions of the CLT relax conditions such as independence and identical distributions, but require additional conditions such as the Lindeberg condition. See Chapter 3 of Durrett’s Probability: Theory and Examples for details.

Appendix B: Adjusting for Different Assignment Probabilities

Section 3.4 discussed bias caused by changing assignment probabilities together with differences in time composition. Inverse probability weighting gives greater weight to users with lower assignment probabilities, so the treatment and control terms recover each user’s respective potential outcomes in expectation. This idea comes from the Horvitz–Thompson estimator.

Let user ii have probability πi\pi_i of entering treatment and 1−πi1-\pi_i of entering control, both known and nonzero. Adjusting each observed value by its assignment probability gives:

τ^IPW:=1n∑i=1n ⁣[Zi Yiobsπi−(1−Zi) Yiobs1−πi].\hat{\tau}_{\text{IPW}} := \frac{1}{n} \sum_{i=1}^{n} \!\left[\frac{Z_i \, Y_i^{\text{obs}}}{\pi_i} - \frac{(1 - Z_i) \, Y_i^{\text{obs}}}{1 - \pi_i}\right].

The treatment term has expectation Yi(1)Y_i(1) and the control term Yi(0)Y_i(0), so the overall expectation remains τ\tau. This correction does not require identical assignment probabilities across users, but does require known, correct probabilities.

When some assignment probabilities approach zero or one, a few observations receive very large weights, increasing variance. Keeping relative assignment ratios stable in the design is more reliable than depending on large-weight corrections afterward. For comparisons of IPW with other methods, see Chapters 12–15 of Imbens and Rubin’s Causal Inference for Statistics, Social, and Biomedical Sciences (2015).