M1-009M1: Mathematics & Statistics FundamentalsCommon DistributionsMedium
⚡Flashcard Drill➔Mastery:

Explain the Shape Parameters of the Beta Distribution and Its Applications in Bayesian A/B Testing

📐 Mathematical Definition
f(x;a,b)=xa−1(1−x)b−1B(a,b),E[X]=aa+bf(x;a,b)=\frac{x^{a-1}(1-x)^{b-1}}{B(a,b)},\qquad \mathbb E[X]=\frac{a}{a+b}
⚡ One-Sentence Core Answer
The Beta distribution parameters α\alpha and β\beta function as pseudo-counts of successes and failures, serving as the conjugate prior for Bernoulli trials and enabling closed-form posterior updates in Thompson Sampling.

📌 Key Takeaways

  • •
    Mean is αα+β\frac{\alpha}{\alpha+\beta}; variance shrinks as α+β\alpha+\beta increases (higher certainty).
  • •
    Beta(1,1)\text{Beta}(1, 1) corresponds to the uniform prior U(0,1)\mathcal{U}(0, 1); α,β<1\alpha, \beta < 1 produces bimodal U-shapes.
  • •
    Bayesian updating: observing ss successes and ff failures transforms Beta(α,β)→Beta(α+s,β+f)\text{Beta}(\alpha, \beta) \to \text{Beta}(\alpha+s, \beta+f).

📐 Mathematical Derivations

The Beta PDF is f(p;α,β)=1B(α,β)pα−1(1−p)β−1f(p; \alpha, \beta) = \frac{1}{B(\alpha, \beta)} p^{\alpha-1} (1-p)^{\beta-1} for p∈[0,1]p \in [0, 1]. When observing kk conversions out of nn impressions under Bernoulli likelihood L(p)=(nk)pk(1−p)n−kL(p) = \binom{n}{k} p^k (1-p)^{n-k}, the posterior density is P(p∣D)∝L(p)f(p)∝pk(1−p)n−k⋅pα−1(1−p)β−1=p(α+k)−1(1−p)(β+n−k)−1P(p\mid D) \propto L(p) f(p) \propto p^k (1-p)^{n-k} \cdot p^{\alpha-1} (1-p)^{\beta-1} = p^{(\alpha+k)-1} (1-p)^{(\beta+n-k)-1}. This matches Beta(α+k,β+n−k)\text{Beta}(\alpha+k, \beta+n-k) without requiring integration, proving conjugacy. In Multi-Armed Bandits (Thompson Sampling), an arm's conversion rate is sampled from pi∼Beta(αi,βi)p_i \sim \text{Beta}(\alpha_i, \beta_i) and the action with maximum sample is executed, optimally balancing exploration and exploitation.

🏭 Production Trade-offs

Beta-Bernoulli Bayesian A/B testing allows continuous monitoring without alpha-spending penalties (avoiding the classical frequentist peeking problem). It answers intuitive business questions like P(pB>pA)P(p_B > p_A) directly via Monte Carlo sampling. However, it requires choosing a credible prior Beta(α0,β0)\text{Beta}(\alpha_0, \beta_0); an overly aggressive prior can bias small-sample results.
⚠️ Common Interview Pitfalls
  • ✕
    Setting uninformative priors like Beta(1,1)\text{Beta}(1, 1) in ad click optimization where baseline CTR is 0.01, creating huge prior distortions.
  • ✕
    Assuming Beta distributions handle continuous reward variables without transformation.
🎯 Interviewer Follow-up Inquiries
  • ?
    How does Thompson Sampling with Beta priors achieve logarithmic regret asymptotically?
  • ?
    How is the probability P(pB>pA)P(p_B > p_A) computed analytically or numerically from two Beta posteriors?
⚡
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-008: Explain Why the Gaussian Distribution is Ubiquitous and Provide the Formal Statement of the Central Limit Theorem📋Back to BankNext →M1-010: Define Heavy-Tailed Distributions and Assess Their Impact on Mean Estimation and A/B Testing
中文速览与面试要点

解释 Beta 分布的形状参数含义,以及它在 A/B 测试中的应用。

Beta(a,b) 定义在 [0,1],a、b 可理解为'成功/失败伪计数';是 Bernoulli 的共轭先验。

核心要点

  • Beta(a,b) 的密度正比于 x^a−1(1−x)^b−1,形状由 a、b 相对大小决定:a=b 时对称(a=b=1 即均匀分布);a>1,b>1 时单峰;a<1 或 b<1 时在端点发散(U 型)。把它看成'伪计数'后,共轭更新极其简洁:若先验 Beta(a,b),观测到 s 次成功、f 次失败,则后验为 Beta(a+s,b+f)——后验均值 (a+s)/(a+b+s+f) 恰是带平滑的样本比例,平滑强度由 a+b 控制。这正是 CTR 平滑的贝叶斯解释:Beta(1,1) 先验给出拉普拉斯平滑,Beta(α,β) 给出更强的先验收缩。
  • 工业应用有三条主线:① Thompson Sampling :多臂老虎机中直接从各臂的后验 Beta 采样并选最大值,天然平衡探索与利用,且比 UCB 更易扩展到复杂奖励;② 贝叶斯 A/B 测试 :直接报告 P(p_A>p_B) 与预期损失,避免频率派 p 值的'无差异'困境,且允许中途查看(无 peeking 问题,因为后验随数据更新是合法的);③ 冷启动平滑 :新商品/新用户点击率用 Beta 先验收缩到全局均值,防止 1/1=100% 的极端估计。局限在于共轭只对指数族成立,复杂模型需 MCMC/变分近似。Dirichlet 是 Beta 的多类别推广,用于多项分布的共轭先验。
  • 后验更新极简:观察 s 次成功、f 次失败 → Beta(a+s, b+f)
  • Thompson Sampling 直接从后验采样决策

常见陷阱

  • 把 a、b 当作概率而非计数
  • 先验强度过大导致后验被先验主导(数据量小时尤甚)