Skip to content
BIASED
Back to topic

Optional

Beta–Binomial posterior after heads

Update Beta(α,β) after h heads and t tails; match mean and a 4/5-style predictive.

Version
v1
Minutes
~20
Evidence
Self-check in the notebook

Until platform auto-check exists, compare cell output with the expected numbers in the notebook. This is not a debt and does not affect mastery.

Download .ipynb

Download the notebook and run it locally. Its environment requirements are listed inside.

Notebook contents

Readable on your phone. The code below has not been executed in the browser; download the notebook to run it.

Bayes · Beta–Binomial апостериор / Beta–Binomial posterior

Activity version: 1 · Seed: n/a · Данные: prior Beta(1,1)\mathrm{Beta}(1,1), данные h=3h=3 орла, t=0t=0 решек.

Ожидаемые числа
Quantity Value Tolerance
posterior (α′,β′)(\alpha',\beta') (4,1)(4,1) exact
posterior mean 0.80.8 abs ≤ 1e-12
posterior predictive P(next=H)P(\text{next}=H) 0.80.8 abs ≤ 1e-12
Самопроверка в ноутбуке

Не влияет на mastery.

import numpy as np
 
alpha, beta = 1.0, 1.0
h, t = 3, 0
alpha_post, beta_post = alpha + h, beta + t
mean = alpha_post / (alpha_post + beta_post)
pred_h = mean  # Bernoulli predictive under Beta
print(alpha_post, beta_post, mean, pred_h)
assert (alpha_post, beta_post) == (4, 1)
assert abs(mean - 0.8) < 1e-12
assert abs(pred_h - 0.8) < 1e-12
print("OK: Beta-Binomial posterior")
Самопроверка в ноутбуке
  • апостериор Beta(4,1)\mathrm{Beta}(4,1)
  • mean = predictive = 0.80.8