M1-050M1: Mathematics & Statistics FundamentalsConfidence Intervals & BootstrapHard
⚡Flashcard Drill➔Mastery:
Detail How to Apply Bootstrap to Evaluate Statistical Significance in A/B Testing and Identify Key Pitfalls
📐 Mathematical Definition
⚡ One-Sentence Core Answer
In A/B testing, bootstrap resamples users within treatment and control independently, constructing a confidence interval for difference ; statistical significance is established if zero falls outside the interval.
📌 Key Takeaways
- •Stratified resampling: Must resample Treatment and Control groups independently to preserve respective sample sizes and .
- •Significance criterion: Reject at level if .
- •Primary advantage: Seamlessly handles non-normal, ratio, and quantile metrics (P95 latency, Revenue per Converter).
📐 Mathematical Derivations
Algorithm for two-sample A/B bootstrap: Given control sample and treatment sample : (1) For : Resample points with replacement from to form , and resample points with replacement from to form . (2) Compute the metric of interest for both groups: and . (3) Compute the difference . (4) Construct the empirical percentile interval . If is not contained within the interval, the treatment effect is statistically significant at significance level .
🏭 Production Trade-offs
Common production pitfalls: (1) Wrong randomization unit: Resampling page views or sessions when users were randomized produces overly narrow confidence intervals (massive false positives due to intra-user correlation). Resampling must strictly occur at the User Level (Cluster Bootstrap). (2) Computational scaling: On billions of rows, running standard bootstrap is cost-prohibitive; platforms use Delta Method for ratio metrics or Poisson Bootstrap on pre-aggregated user stats.
⚠️ Common Interview Pitfalls
- ✕Pooling data and resampling globally across groups, which forces sample sizes to fluctuate randomly.
- ✕Resampling at the impression/click level instead of the user level, violating the i.i.d. assumption and severely inflating Type I error.
🎯 Interviewer Follow-up Inquiries
- ?How does cluster bootstrap resample at the user level when evaluating session-level or query-level metrics?
- ?Why does the Delta Method provide an instantaneous analytical alternative to Bootstrap for ratio metrics?
⚡
Test muscle memory on this topic via 3-Layer Flashcards
Active Recall: Mentally formulate Prompt ➔ Math Derivation ➔ Benchmark Implementation in 3 minutes.
📚
Associated Knowledge Base Guides & Mindmaps
Explore the comprehensive technical article, exam cards, and global architecture tree.
中文速览与面试要点
如何用 bootstrap 做 A/B 测试的显著性判断?有什么坑。
对两组分别重采样,计算差值分布的分位数;坑:重尾、极小样本、多重指标、重复抽样需固定随机种子。
核心要点
- 正确做法:① 对 A、B 两组 分别 做有放回重采样(各 n_A、n_B 次);② 每次计算统计量差值 Δ*_b=stat(A*_b)−stat(B*_b)(注意是 差值分布 ,而非分别构造两个 CI);③ 取 Δ* 分布的分位数作为差值的置信区间,或计算 P(Δ*>0)(单侧)与 (1+min(2P(Δ*≤0), 2P(Δ*≥0)))(双侧 p 值)。 关键点:必须对差值做 bootstrap ,因为两组独立时 Var(A−B)=Var(A)+Var(B),而'分别构造 CI 再比较'会忽略协方差且无法给出差值的精确区间——这正是'两个 CI 重叠但不显著'这一常见困惑的根源(CI 重叠与否是比显著性检验 更保守 的判据)。
- 四个必须注意的坑:① 重尾指标 ——点击/消费/延迟类指标重尾,bootstrap 方差估计不稳定,应先做 CUPED 降方差或对指标做截断(winsorize),并增大 B;② 极小样本/稀有事件 ——若某组转化数极少(如 分层与配对结构 ——若实验采用分层随机化或配对设计,bootstrap 必须在层内/对内进行(stratified bootstrap),否则会低估方差;④ 计算成本与可复现性 ——B=10000 时对 10⁸ 用户做重采样代价高昂,实践中常用 泊松 bootstrap (对每个用户的贡献乘独立泊松权重)或对聚合统计量做 bootstrap;同时必须固定随机种子以保证结果可复现,并注意多次实验的随机种子不应重复使用。
- 差值法比分别构造 CI 再比较更正确
- 计算成本高,需缓存/并行
- 不能替代实验设计(功效/分流/污染)
常见陷阱
- 分别构造两组 CI 后比较是否重叠
- 对稀有事件(转化数极少)直接用 bootstrap