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
Δ(b)∗=stat(A(b)∗)−stat(B(b)∗)\Delta^*_{(b)}=\mathrm{stat}(A^*_{(b)})-\mathrm{stat}(B^*_{(b)})
⚡ One-Sentence Core Answer
In A/B testing, bootstrap resamples users within treatment and control independently, constructing a confidence interval for difference Δ=YˉB−YˉA\Delta = \bar{Y}_B - \bar{Y}_A; 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 NAN_A and NBN_B.
  • •
    Significance criterion: Reject H0:Δ=0H_0: \Delta = 0 at level α\alpha if 0∉[Δα/2∗,Δ1−α/2∗]0 \notin [\Delta^*_{\alpha/2}, \Delta^*_{1-\alpha/2}].
  • •
    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 DA={x1,…,xNA}D_A = \{x_1, \dots, x_{N_A}\} and treatment sample DB={y1,…,yNB}D_B = \{y_1, \dots, y_{N_B}\}: (1) For b=1,…,Bb = 1, \dots, B: Resample NAN_A points with replacement from DAD_A to form DA∗bD_A^{*b}, and resample NBN_B points with replacement from DBD_B to form DB∗bD_B^{*b}. (2) Compute the metric of interest for both groups: θA∗b=g(DA∗b)\theta_A^{*b} = g(D_A^{*b}) and θB∗b=g(DB∗b)\theta_B^{*b} = g(D_B^{*b}). (3) Compute the difference Δ∗b=θB∗b−θA∗b\Delta^{*b} = \theta_B^{*b} - \theta_A^{*b}. (4) Construct the empirical percentile interval [Δα/2∗,Δ1−α/2∗][\Delta^*_{\alpha/2}, \Delta^*_{1-\alpha/2}]. If 00 is not contained within the interval, the treatment effect is statistically significant at significance level α\alpha.

🏭 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 NA,NBN_A, N_B 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.
🎯 Drill This Card Now➔
📚

Associated Knowledge Base Guides & Mindmaps

Explore the comprehensive technical article, exam cards, and global architecture tree.

← PreviousM1-049: Contrast Bootstrap vs. Permutation Tests and Detail Their Respective Valid Assumptions and Use Cases📋Back to BankNext →M1-051: Describe the End-to-End Operational Lifecycle of a Standard Industrial A/B Experiment
中文速览与面试要点

如何用 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