1 정의
Kohavi (2020) Ch.18.1 의 3 가지 함정. 각각 다른 종류의 metric 에서 발생.
| 함정 | 발생 metric | 결과 |
|---|---|---|
| Delta vs Delta % | Relative metric (%) | Variance underestimate or wrong scale |
| Ratio Metrics i.i.d. 위반 | Ratio (CTR, RPC) | Variance underestimate (within-user correlation) |
| Outliers | All metrics | Variance overestimate (false negative) |
원문 (Ch.18.1): “If you incorrectly estimate the variance, then the p-value and confidence interval will be incorrect, making your conclusions from the hypothesis test wrong.”
핵심 통찰: 세 함정 모두 Naive 분석 가능 하지만 잘못된 결론. Modern platform 의 정확성 은 이 함정들을 자동 보정.
2 개념 및 원리
2.1 함정 1 — Delta vs Delta %
2.1.1 Delta % 의 정의
저자 명시 (Equation 18.1):
\[\Delta\% = \frac{\Delta}{\overline{Y^c}} = \frac{\overline{Y^t} - \overline{Y^c}}{\overline{Y^c}}\]
여기서 \(\overline{Y^t}\) 는 Treatment mean, \(\overline{Y^c}\) 는 Control mean.
2.1.1.1 Why 보고 시 Delta % 선호
Absolute (Δ):
"0.01 sessions per user" → 의미 모호
Cross-context 비교 어려움
Relative (Δ%):
"+5% sessions" → 직관적
Cross-context 비교 가능 (다른 metric 의 +5% 와 비교)
2.1.2 Delta 의 Variance — 단순
Var(Δ) = Var(Ȳ_t - Ȳ_c) = Var(Ȳ_t) + Var(Ȳ_c)
(Treatment 와 Control 이 independent 이므로 covariance 0)
이 공식은 직관적·단순.
2.1.3 Delta % 의 Variance — Common Mistake
저자 강조: “a common mistake is to divide \(var(\Delta)\) by \(\overline{Y}^{c^2}\).”
잘못된 추정:
Var(Δ%) ≈ Var(Δ) / Ȳ_c²
이 잘못된 이유:
Ȳ_c 자체가 random variable (variance 있음)
Var(Δ%) 는 ratio 의 variance
Variance of ratio ≠ Variance of numerator / denominator²
2.1.3.1 잘못된 추정의 결과
Variance underestimate or overestimate (case 의존):
- Mean Δ 와 mean Y_c 의 correlation 이 영향
- Treatment vs Control 의 mean 차이가 클 때 더 잘못
영향:
Underestimate: false positive ↑
Overestimate: false negative ↑
2.1.4 올바른 추정 — Delta Method
저자 강조: “We will discuss how to estimate the variance of the ratio.”
2.1.4.1 일반 공식 (Equation 18.5)
\[\text{Var}(M) = \frac{1}{\bar{Y}^2}\text{Var}(\bar{X}) + \frac{\bar{X}^2}{\bar{Y}^4}\text{Var}(\bar{Y}) - 2\frac{\bar{X}}{\bar{Y}^3}\text{Cov}(\bar{X}, \bar{Y})\]
여기서 \(M = \bar{X}/\bar{Y}\) (general ratio).
2.1.4.2 Delta % 의 경우
저자 명시 (Equation 18.6): Treatment 와 Control 이 independent (Cov = 0):
\[\text{Var}(\Delta\%) = \frac{1}{\overline{Y^c}^2}\text{Var}(\overline{Y^t}) + \frac{\overline{Y^t}^2}{\overline{Y^c}^4}\text{Var}(\overline{Y^c})\]
2.1.4.3 이 정확한 공식과 잘못된 공식의 차이
Naive: Var(Δ%) ≈ Var(Δ) / Ȳ_c²
= (Var(Ȳ_t) + Var(Ȳ_c)) / Ȳ_c²
Correct: Var(Δ%) = Var(Ȳ_t)/Ȳ_c² + Ȳ_t² × Var(Ȳ_c) / Ȳ_c⁴
차이:
Naive 의 Var(Ȳ_c) coefficient: 1/Ȳ_c²
Correct 의 Var(Ȳ_c) coefficient: Ȳ_t²/Ȳ_c⁴ = (Ȳ_t/Ȳ_c)² / Ȳ_c²
만약 Treatment 가 Control 보다 5% 크면:
Ȳ_t / Ȳ_c = 1.05
(Ȳ_t/Ȳ_c)² = 1.1025
Correct 가 Naive 보다 10% 더 큼
이 10% 차이가 statistical significance 의 boundary 에서 결과를 바꿀 수 있음.
2.1.5 Delta Method 의 유도 — Taylor Expansion
2.1.5.1 First-order Taylor
Function f(X̄, Ȳ) = X̄/Ȳ 의 1st-order Taylor at (μ_X, μ_Y):
f(X̄, Ȳ) ≈ μ_X/μ_Y + (1/μ_Y)(X̄ - μ_X) - (μ_X/μ_Y²)(Ȳ - μ_Y)
Variance:
Var(f) ≈ (1/μ_Y)² × Var(X̄)
+ (μ_X/μ_Y²)² × Var(Ȳ)
- 2 × (1/μ_Y) × (μ_X/μ_Y²) × Cov(X̄, Ȳ)
= (1/μ_Y²) Var(X̄)
+ (μ_X²/μ_Y⁴) Var(Ȳ)
- 2 × (μ_X/μ_Y³) Cov(X̄, Ȳ)
이 유도가 delta method 의 본질. Linear approximation 의 variance.
2.1.5.2 정확성
Delta method:
- 1st-order linear approximation
- 2nd-order term 은 무시
- Sample size 큼 → 정확
Sample size 작음 시:
- Linear approximation 부정확
- Bootstrap 또는 simulation 권고
2.2 함정 2 — Ratio Metrics 의 i.i.d. 위반
저자 명시 (Ch.18.1 Ratio Metrics 의 본문).
2.2.1 Ratio Metrics 의 예
CTR (Click-Through Rate):
CTR = total clicks / total pageviews
Revenue per Click:
RPC = total revenue / total clicks
Conversion rate:
CR = total conversions / total visits
Bounce rate:
BR = total bounces / total sessions
각 ratio 는 다른 unit 의 ratio. CTR 의 unit 은 page, RPC 의 unit 은 click.
2.2.2 i.i.d. 가정의 위반 메커니즘
저자 강조: “for page-level metrics, each \(Y_i\) represents a measurement for a page while the experiment is randomized by user, so \(Y_1, Y_2\) and \(Y_3\) could all be from the same user and are ‘correlated.’ Because of such ‘within user correlation,’ variance computed using the simple formula would be biased.”
2.2.2.1 시나리오
실험: User-level randomization
Metric: CTR (page-level)
User Alice: 10 pages, 2 clicks (CTR: 20%)
User Bob: 10 pages, 1 clicks (CTR: 10%)
User Carol: 5 pages, 0 clicks (CTR: 0%)
Page-level data:
Y_1 = 1 (Alice page 1, click)
Y_2 = 0 (Alice page 2, no click)
...
Y_10 = 0 (Alice page 10)
Y_11 = 1 (Bob page 1, click)
...
Within-user correlation:
Alice 의 모든 page 가 Alice 의 의도·성향 공유
→ Y_1 ~ Y_10 이 correlated
→ i.i.d. 위반
2.2.3 간단한 분산 공식의 왜곡
Standard:
s² = (1/(n-1)) × Σ (Y_i - Ȳ)²
가정:
각 Y_i 가 독립 → s²/n 이 Var(Ȳ) 의 unbiased estimate
위반 시:
Y_i 가 correlated
s² 자체는 unbiased estimate of σ²
but Var(Ȳ) 는 σ²/n 보다 큼 (positive correlation 시)
→ s²/n 가 underestimate Var(Ȳ)
→ SE underestimate
→ t-stat overestimate
→ False positive ↑
2.2.3.1 시각화
True scenario:
Var(Ȳ) (with correlation) = σ² × (1 + (n-1) × ρ) / n
where ρ = within-user correlation
ρ=0 (i.i.d.): Var(Ȳ) = σ²/n (correct)
ρ=0.3: Var(Ȳ) = σ² × (1 + 0.3(n-1))/n ≈ σ² × 0.3 (n=100)
→ Naive estimate 가 실제의 1/30
→ SE 가 1/√30 = 18%
→ t-stat 5x overestimate
이 underestimation 이 ratio metric 분석의 systemic problem.
2.2.4 해결 — User-level Aggregation
저자 명시: “you can write the ratio metric as the ratio of ‘average of user level metrics.’”
2.2.4.1 Equation 18.4
\[M = \frac{\bar{X}}{\bar{Y}}\]
여기서:
- \(\bar{X}\) = average user-level metric (예: clicks per user)
- \(\bar{Y}\) = average user-level metric (예: pageviews per user)
2.2.4.2 변환
Original (page-level):
CTR_naive = Σ_pages clicks / Σ_pages pageviews
User-level version:
X_i = user i 의 clicks
Y_i = user i 의 pageviews
X̄ = Σ X_i / N_users
Ȳ = Σ Y_i / N_users
M = X̄ / Ȳ
수학적 동일:
M = (Σ X_i / N) / (Σ Y_i / N) = Σ X_i / Σ Y_i = CTR_naive
Variance 추정:
X̄, Ȳ 가 user-level → i.i.d. 가정 hold
Delta method 의 (X̄, Ȳ) 의 ratio variance 적용
이 reformulation 이 ratio metric 분석의 표준.
2.2.5 비교 — Naive vs Delta Method
Naive variance estimate:
s²_pages / n_pages
→ Underestimate (within-user correlation 무시)
Delta method:
Var(M) = (1/Ȳ²)Var(X̄) + (X̄²/Ȳ⁴)Var(Ȳ) - 2(X̄/Ȳ³)Cov(X̄,Ȳ)
→ Correct (user-level i.i.d. 가정 hold)
2.2.6 Bootstrap Alternative
저자 명시: “there are metrics that cannot be written in the form of the ratio of two user-level metrics, for example, 90th percentile of page load time. For these metrics, we may need to resort to bootstrap method.”
2.2.6.1 90th Percentile 의 challenge
90th percentile of PLT (Page Load Time):
- User-level user-aggregation 어려움
- User 의 90th percentile vs all-page 90th percentile 다름
- Ratio of two user-level metric 형태 안 됨
Bootstrap:
- User pool 에서 random N users (with replacement)
- 이 sample 의 모든 page 의 90th percentile 계산
- 1000 회 반복
- 1000 개 quantile 의 분포 → empirical SE
2.2.6.2 Bootstrap 의 cost
Cost:
- 매 sample 마다 sort (90th percentile 계산)
- 1000 회 반복
- 큰 dataset (수백만 page) 에서 매우 비쌈
해결:
- Sample sub-set 사용 (10% sample)
- 또는 percentile 의 asymptotic variance (Lehmann and Romano 2005)
- Density estimation (Liu et al. 2018)
저자 인용 (Liu et al. 2018): density estimation + delta method 의 hybrid 가 산업 표준.
2.3 함정 3 — Outliers
저자 명시 (Ch.18.1 Outliers).
2.3.1 Outlier 의 source
1. Bot/Spam:
- 거대 traffic 의 single ID
- Pattern 인지 가능 (Ch.16)
2. Bug 사용자:
- Browser bug 로 자동 click
- Endless loop 의 page reload
- Real user 지만 anomalous
3. Power user:
- Real user, but extreme behavior
- 1000 search per day 가능 (real)
- Bot 와 구별 어려움
2.3.2 Mean·Variance 비대칭 영향
저자 강조: “Outliers have a big impact on both the mean and variance. In statistical testing, the impact on the variance tends to outweigh the impact on the mean.”
2.3.2.1 정량적 분석
Standard data:
N=10,000 사용자
평균 = 5
Std = 2 → Variance = 4
Add 1 outlier (value=1000):
새 평균: (50000 + 1000) / 10001 ≈ 5.1 (영향 minimal)
새 variance: 거의 (1000 - 5)² / 10000 ≈ 99.0 (영향 25x)
Mean 영향: 2%
Variance 영향: 2475%
2.3.2.2 t-statistic 의 영향
t = (Mean_T - Mean_C) / SE
SE = √(Var/N)
Outlier in Treatment:
Mean_T 약간 ↑ (numerator 증가)
Var_T dramatic ↑ → SE ↑ (denominator 더 증가)
결과:
t-stat 감소
Statistical significance 사라짐
2.3.3 Figure 18.1 의 시각화 (저자)
Outlier multiplier (relative to true delta):
0x: t very high (highly significant)
1x: t high (significant)
5x: t medium (marginal)
10x: t low (not significant)
20x: t very low (definitely not significant)
2.3.3.1 메커니즘
Outlier effect on t:
t = effect_size / SE
≈ effect / √(σ² + outlier_contribution / N)
Outlier_contribution ∝ outlier_value²
Outlier 의 size 증가 시:
Numerator (effect) 거의 unchanged
Denominator (SE) dramatic 증가
t-stat 의 거의 inverse-square decay
2.3.4 Capping — 핵심 해결
저자 명시: “A practical and effective method is to simply cap observations at a reasonable threshold.”
2.3.4.1 Capping 의 메커니즘
Threshold 결정:
Domain knowledge:
- Search: 500/day
- Pageviews: 1000/day
- Sessions: 50/day
또는 statistical:
- Top 0.1% percentile
- Top 1% percentile
- 3 sigma rule
Apply:
Y_capped_i = min(Y_i, threshold)
Effect:
- Outlier value 가 threshold 로 제한
- Mean 변화 minimal (대부분 user 가 threshold 미만)
- Variance 변화 dramatic (outlier 의 quadratic 영향 제거)
2.3.4.2 Capping 의 trade-off
장점:
- Variance 정상화
- Statistical significance 회복
- Trustworthy 분석
단점:
- 정보 손실 (threshold 초과 부분)
- Real heavy user 의 contribution 도 cap
- Bias 가능 (rare event 의 진정 mean 측정 어려움)
대부분 case:
- Capping 의 bias 거의 0 (threshold 적절 시)
- Variance 회복의 가치가 훨씬 큼
2.3.5 다른 Outlier Methods
저자 인용 (Hodge and Austin 2004).
2.3.5.1 Method 1 — Winsorization
Cap 의 양면 version:
Bottom 1% → 1st percentile value
Top 1% → 99th percentile value
Middle 98% 그대로
Effect:
Mean: very minimal 변화
Variance: 정상화
2.3.5.2 Method 2 — Trimming
Cap 대신 제거:
Top 1% 제거
Bottom 1% 제거
Effect:
Sample size 약간 ↓ (2%)
Mean: minimal 변화
Variance: 정상화
Capping vs Trimming:
Capping: data 보존, 정보 일부 (cap 의 binary)
Trimming: data 제거, 정보 0
대부분 같은 effect
2.3.5.3 Method 3 — Robust Statistics
Mean 대신 Median:
Outlier 영향 거의 0
단 통계 검정 더 복잡 (분포 가정)
Std 대신 MAD (Median Absolute Deviation):
Outlier 영향 거의 0
2.3.5.4 Method 4 — Z-score 기반
Z = (Y - mean) / std
|Z| > 3 → outlier
문제:
Outlier 가 std 자체를 inflate → outlier detection 약화
Iterative method 필요 (단계적 제거)
2.3.5.5 산업 표준
Pipeline 의 outlier handling:
Stage 1: Bot detection (Ch.16)
- 명백한 anomaly 제거 (full session 제거)
Stage 2: Capping
- Per-user 또는 per-session 의 metric cap
- Domain-specific threshold
Stage 3: Robust analysis (optional)
- Median, MAD
- Mean-based 분석의 supplement
이 multi-layer 가 modern outlier handling.
2.3.5.6 모든 함정의 공통 root
세 함정의 root cause: Variance estimation 의 simplification.
Variance estimation 의 잘못:
1. Delta % 의 ratio 정의 무시 → naive division
2. Within-user correlation 무시 → simple formula
3. Outlier 영향 무시 → raw variance
각각이 다른 layer 의 simplification.
2.3.5.7 Modern Platform 의 자동 보정
Default 분석 pipeline:
Step 1: Outlier handling (capping)
→ Variance 정상화
Step 2: User-level aggregation (ratio metric)
→ i.i.d. 가정 회복
Step 3: Delta method (relative metric)
→ 정확한 ratio variance
Step 4: 통계 검정 (t-test, z-test)
→ Trustworthy p-value
Step 5: Trust check (SRM, AA)
→ Pipeline 검증
이 5 단계가 보장하는 것: Naive 분석의 함정 모두 자동 처리. Engineer 가 분석 자체에 신경 안 써도 trustworthy.
2.3.5.8 Engineer 의 mental model
잘못된 모델: "Variance 는 단순 계산"
→ 자체 분석 시 함정
올바른 모델: "Variance 는 미묘함, platform 에 위임"
→ Platform 의 자동 처리 사용
→ 잘못된 분석 회피
이 mental model 이 platform-driven 의사결정의 본질.
3 왜 필요한가
3 함정 보정 부재 시.
- Pitfall 1 (Delta %): variance 잘못 → significance 잘못
- Pitfall 2 (Ratio): i.i.d. 위반 → false positive ↑
- Pitfall 3 (Outlier): variance inflate → false negative ↑
- Trust 위기: 분석 결과의 신뢰 약화
- Decision quality ↓: 잘못된 launch 또는 reject
활성 시.
- 정확한 variance: trustworthy p-value, CI
- 올바른 ratio: delta method 또는 bootstrap
- Outlier robustness: capping 의 자동 적용
- Trust 회복: A/A 검증 통과
- Decision quality: 잘못된 결정 회피
이 함정 처리가 statistical maturity 의 본질. Run·Fly 단계의 표준.
4 응용 사례 — Bing 의 CTR 분석
Bing 의 CTR 분석:
Pipeline:
Step 1: Bot detection (Ch.16)
Step 2: Per-user aggregation:
- User i 의 clicks (X_i)
- User i 의 pageviews (Y_i)
Step 3: Delta method:
- CTR_T = ΣX_T / ΣY_T (Treatment)
- CTR_C = ΣX_C / ΣY_C (Control)
- Δ% = (CTR_T - CTR_C) / CTR_C
- Var(Δ%) = correct delta method formula
Trust check:
- SRM check (Ch.21)
- A/A check
- Capping (X_i, Y_i 의 outlier)
Result:
Trustworthy CTR effect estimate.
False positive 자동 보호.
이 운영이 Bing 의 일별 분석 표준. ExP platform 이 자동 처리.
5 코드 예시 — Naive vs Delta Method 비교
CTR 분석 의 두 방법 의 결과 차이.
import numpy as np
import pandas as pd
from scipy import stats
rng = np.random.default_rng(42)
# 시뮬레이션: 1000 users, user-level randomization
n_users = 1000
n_pages_per_user = lambda: max(1, int(rng.lognormal(2, 1)))
# 데이터 생성
data = []
for i in range(n_users):
user_id = f"user_{i:04d}"
treatment = rng.choice([0, 1])
n_pages = n_pages_per_user()
base_ctr = 0.05 # 5%
user_ctr = base_ctr * 1.05 if treatment else base_ctr # +5% lift if T
for j in range(n_pages):
click = rng.binomial(1, user_ctr)
data.append({
"user_id": user_id,
"treatment": treatment,
"page_id": f"{user_id}_p{j}",
"click": click,
"pageview": 1
})
df = pd.DataFrame(data)
print(f"Total pageviews: {len(df)}")
print(f"Total users: {df['user_id'].nunique()}")
print(f"Pageviews per user: {len(df)/df['user_id'].nunique():.1f}")
# === Naive (page-level i.i.d. 가정 — 잘못) ===
print("\n=== Naive (page-level) ===")
t_pages = df[df["treatment"] == 1]
c_pages = df[df["treatment"] == 0]
t_ctr = t_pages["click"].sum() / t_pages["pageview"].sum()
c_ctr = c_pages["click"].sum() / c_pages["pageview"].sum()
delta_naive = t_ctr - c_ctr
delta_pct_naive = delta_naive / c_ctr
# Naive SE (binomial assumption)
n_t = t_pages["pageview"].sum()
n_c = c_pages["pageview"].sum()
se_t_naive = np.sqrt(t_ctr * (1 - t_ctr) / n_t)
se_c_naive = np.sqrt(c_ctr * (1 - c_ctr) / n_c)
se_delta_naive = np.sqrt(se_t_naive**2 + se_c_naive**2)
se_delta_pct_naive = se_delta_naive / c_ctr # 잘못된 추정!
z_naive = delta_pct_naive / se_delta_pct_naive
p_naive = 2 * (1 - stats.norm.cdf(abs(z_naive)))
print(f"CTR_T: {t_ctr:.4f}, CTR_C: {c_ctr:.4f}")
print(f"Δ%: {delta_pct_naive*100:.2f}%")
print(f"SE(Δ%): {se_delta_pct_naive:.5f}")
print(f"Z: {z_naive:.2f}, p: {p_naive:.4f}")
# === Delta Method (user-level — 올바른) ===
print("\n=== Delta Method (user-level) ===")
user_summary = df.groupby(["user_id", "treatment"]).agg({
"click": "sum",
"pageview": "sum"
}).reset_index()
t_users = user_summary[user_summary["treatment"] == 1]
c_users = user_summary[user_summary["treatment"] == 0]
# User-level X (clicks) 와 Y (pageviews)
def delta_method_ctr(group):
X = group["click"]
Y = group["pageview"]
n = len(group)
X_mean = X.mean()
Y_mean = Y.mean()
R = X_mean / Y_mean
Var_X = X.var()
Var_Y = Y.var()
Cov_XY = np.cov(X, Y, ddof=1)[0, 1]
Var_R = (1 / Y_mean**2) * Var_X / n \
+ (X_mean**2 / Y_mean**4) * Var_Y / n \
- 2 * (X_mean / Y_mean**3) * Cov_XY / n
SE_R = np.sqrt(max(0, Var_R))
return R, SE_R
t_ctr_delta, t_se_delta = delta_method_ctr(t_users)
c_ctr_delta, c_se_delta = delta_method_ctr(c_users)
delta_pct_correct = (t_ctr_delta - c_ctr_delta) / c_ctr_delta
# Delta % variance (Equation 18.6)
var_delta_pct = (1 / c_ctr_delta**2) * t_se_delta**2 \
+ (t_ctr_delta**2 / c_ctr_delta**4) * c_se_delta**2
se_delta_pct_correct = np.sqrt(var_delta_pct)
z_correct = delta_pct_correct / se_delta_pct_correct
p_correct = 2 * (1 - stats.norm.cdf(abs(z_correct)))
print(f"CTR_T: {t_ctr_delta:.4f}, CTR_C: {c_ctr_delta:.4f}")
print(f"Δ%: {delta_pct_correct*100:.2f}%")
print(f"SE(Δ%): {se_delta_pct_correct:.5f}")
print(f"Z: {z_correct:.2f}, p: {p_correct:.4f}")
# === 비교 ===
print("\n=== 비교 ===")
print(f"Naive SE: {se_delta_pct_naive:.5f}")
print(f"Correct SE: {se_delta_pct_correct:.5f}")
print(f"Naive 가 underestimate factor: {se_delta_pct_correct / se_delta_pct_naive:.2f}x")
print(f"\nNaive p: {p_naive:.4f} ({'significant' if p_naive < 0.05 else 'not significant'})")
print(f"Correct p: {p_correct:.4f} ({'significant' if p_correct < 0.05 else 'not significant'})")이 코드의 핵심 메시지.
5.0.0.1 Naive 의 underestimate
일반적 결과:
Naive SE: 매우 작음
Correct SE: 1.5~3x 큼
→ Naive 가 SE underestimate
→ Naive p-value 가 더 작음
→ False positive (Naive 가 significant 라 보지만 실제로는 noise)
5.0.0.2 Decision 의 위험
Naive 분석:
- "p < 0.001, 매우 강 효과"
- Launch 결정
Correct (delta method) 분석:
- "p > 0.05, not significant"
- Reject 결정
같은 데이터, 다른 결론. Naive 결정 의 risk:
- Spurious launch
- 실제 효과 없는 feature 의 ROI 잘못 산정
- 다음 실험의 false baseline
5.0.0.3 Why naive 가 가장 흔한 실수
이유:
1. Standard SQL: SUM(click) / SUM(pageview)
2. Standard variance formula: 단순
3. Statistician 이 pipeline 검증 안 하면 빠짐
Modern platform 의 자동 보정:
- 모든 ratio metric 의 user-level aggregation 자동
- Delta method 자동 적용
- Engineer 가 잘못 사용 자체 못 함
이 platform 의 enforcement 가 statistical maturity 의 본질. Naive 분석은 platform 자체가 차단.
6 관련 주제
선행
다음 글
관련 챕터
- F19-* — Ch.19 A/A Test — Variance 검증
- F16-1 — Bot Detection · Capping
다른 카테고리 연결