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 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 , данные орла, решек.
Ожидаемые числа
| Quantity | Value | Tolerance |
|---|---|---|
| posterior | exact | |
| posterior mean | abs ≤ 1e-12 | |
| posterior predictive | 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")Самопроверка в ноутбуке
- апостериор
- mean = predictive =