[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,93 +2,157 @@
|
||||
id: wiki-2026-0508-bayesian-updating
|
||||
title: Bayesian Updating
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [P-Reinforce-AUTO-BAUP-001]
|
||||
aliases: [Bayesian Inference, Posterior Update, Belief Updating]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.99
|
||||
tags: [auto-reinforced, bayesian-updating, learning-mechanisms, adaptive-systems, Feedback-Loops]
|
||||
confidence_score: 0.95
|
||||
verification_status: applied
|
||||
tags: [statistics, inference, probability, ml, decision-theory]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-04-20
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
tech_stack:
|
||||
language: unspecified
|
||||
framework: unspecified
|
||||
language: Python
|
||||
framework: PyMC / NumPyro
|
||||
---
|
||||
|
||||
# [[Bayesian-Updating|Bayesian-Updating]]
|
||||
# Bayesian Updating
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> "유연한 사고의 알고리즘: 틀릴 수 있음을 인정하고, 매 순간 들어오는 새로운 증거를 체로 걸러 기존의 세계관을 조금씩, 그러나 과학적으로 정교하게 수정해 나가는 지능의 학습 원리."
|
||||
## 매 한 줄
|
||||
> **"매 Posterior ∝ Likelihood × Prior — evidence 의 arrival 마다 belief 의 incremental refinement"**. Bayes (1763) 의 sermon 에서 출발 의, 2026 modern stack 의 PyMC 5, NumPyro 0.15, Stan 2.34 의 통한 millions-of-parameters posterior 의 NUTS / HMC sampling 의 routine.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
베이지안 업데이트(Bayesian-Updating)는 관찰된 데이터를 기반으로 가설에 대한 신뢰도를 지속적으로 갱신하는 과정입니다.
|
||||
## 매 핵심
|
||||
|
||||
1. **작동 메커니즘**:
|
||||
* **Initial Belief (Prior)**: "이 에이전트는 신뢰할 수 있다."
|
||||
* **New Evidence**: 에이전트가 예기치 못한 실수를 함.
|
||||
* **Updating (Likelihood calculation)**: 이 실수가 신뢰 가능한 상태에서 나올 확률을 계산.
|
||||
* **Result (Posterior)**: 신뢰도를 하향 조정.
|
||||
2. **지능 시스템에서의 의의**:
|
||||
* **[[Active Learning|Active Learning]]**: 어떤 데이터가 사후 확률을 가장 크게 변화시킬지(즉, 가장 배울 점이 많을지) 판단하여 효율적으로 학습.
|
||||
* **[[Robustness|Robustness]]**: 노이즈 섞인 데이터 하나에 일희일비하지 않고 전체적인 추세에 따라 점진적으로 변화함 (Stability-Flexibility Dilemma 해결).
|
||||
### 매 공식
|
||||
- **Bayes' rule**: `P(H|E) = P(E|H) × P(H) / P(E)`
|
||||
- **Sequential update**: `posterior_t = likelihood_t × posterior_{t-1}`
|
||||
- **Log-form** (numerical stability): `log P(H|E) = log P(E|H) + log P(H) - log P(E)`
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌**: 과거 AI 학습 정책은 '학습된 데이터'에 고착되는 경향(Catastrophic forgetting)이 강했으나, 현대의 베이지안 업데이트 정책은 기존 지식을 보호하며 새 정보를 통합하는 '점진적 학습 정책'을 지향함(RL Update).
|
||||
- **정책 변화(RL Update)**: 사용자 인터페이스(UI) 정책에서, 사용자의 행동 패턴을 실시간으로 베이지안 업데이트하여 인터페이스의 배치나 추천 항목을 동적으로 바꾸는 '초개인화 환경 정책'이 표준이 됨.
|
||||
### 매 conjugate priors
|
||||
- Beta–Binomial (CTR, conversion rate)
|
||||
- Gamma–Poisson (event counts, arrival rate)
|
||||
- Normal–Normal (sensor fusion, A/B continuous metric)
|
||||
- Dirichlet–Multinomial (categorical preferences)
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- [[Bayes-Theorem|Bayes-Theorem]], [[Belief-Revision|Belief-Revision]], [[Active Learning|Active Learning]], Self-Correction Mechanisms, [[Adaptive-Curation|Adaptive-Curation]]
|
||||
- **Modern Tech/Tools**: Reinforcement learning with Bayesian exploration, Online learning algorithms.
|
||||
---
|
||||
### 매 응용
|
||||
1. A/B testing — early-stopping, peeking 의 robust handling.
|
||||
2. Spam filter — Naive Bayes 의 incremental email update.
|
||||
3. Robot localization — particle filter 의 prior 와 sensor likelihood 의 fuse.
|
||||
4. LLM uncertainty — token-level posterior 의 calibration (2026 Anthropic constitutional classifiers).
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
## 💻 패턴
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
### Beta–Binomial conjugate (CTR)
|
||||
```python
|
||||
from scipy import stats
|
||||
import numpy as np
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
# Prior: Beta(1, 1) = uniform
|
||||
alpha, beta = 1.0, 1.0
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
# Observe: 73 clicks out of 1000 impressions
|
||||
clicks, impressions = 73, 1000
|
||||
alpha_post = alpha + clicks
|
||||
beta_post = beta + (impressions - clicks)
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
|
||||
## 💻 코드 패턴 (Code Patterns)
|
||||
|
||||
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
|
||||
|
||||
```text
|
||||
# TODO
|
||||
posterior = stats.beta(alpha_post, beta_post)
|
||||
print(f"Posterior mean CTR: {posterior.mean():.4f}")
|
||||
print(f"95% credible interval: {posterior.interval(0.95)}")
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### Sequential update (online)
|
||||
```python
|
||||
def online_beta_update(alpha, beta, click: bool):
|
||||
return (alpha + click, beta + (1 - click))
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
a, b = 1.0, 1.0
|
||||
for event in stream_of_clicks():
|
||||
a, b = online_beta_update(a, b, event)
|
||||
if a + b > 100: # confident enough
|
||||
decide(stats.beta(a, b).mean())
|
||||
```
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### PyMC 5 hierarchical
|
||||
```python
|
||||
import pymc as pm
|
||||
import numpy as np
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
variants = ["A", "B", "C"]
|
||||
clicks = np.array([73, 91, 82])
|
||||
impressions = np.array([1000, 1010, 990])
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
with pm.Model() as model:
|
||||
mu = pm.Beta("mu", 1, 1)
|
||||
kappa = pm.HalfNormal("kappa", 10)
|
||||
theta = pm.Beta("theta", mu * kappa, (1 - mu) * kappa, shape=len(variants))
|
||||
pm.Binomial("y", n=impressions, p=theta, observed=clicks)
|
||||
idata = pm.sample(2000, tune=1000, target_accept=0.95)
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
pm.summary(idata, var_names=["theta"])
|
||||
```
|
||||
|
||||
### NumPyro NUTS (GPU-accelerated, JAX)
|
||||
```python
|
||||
import numpyro
|
||||
import numpyro.distributions as dist
|
||||
from numpyro.infer import MCMC, NUTS
|
||||
import jax.numpy as jnp
|
||||
|
||||
def model(impressions, clicks=None):
|
||||
p = numpyro.sample("p", dist.Beta(1, 1))
|
||||
numpyro.sample("obs", dist.Binomial(impressions, p), obs=clicks)
|
||||
|
||||
mcmc = MCMC(NUTS(model), num_warmup=500, num_samples=2000)
|
||||
mcmc.run(jax.random.PRNGKey(0), impressions=jnp.array(1000), clicks=jnp.array(73))
|
||||
mcmc.print_summary()
|
||||
```
|
||||
|
||||
### Bayesian online change-point detection
|
||||
```python
|
||||
def bocpd_step(observation, run_length_probs, hazard=1/250):
|
||||
"""Adams & MacKay 2007."""
|
||||
pred = compute_predictive_prob(observation, run_length_probs)
|
||||
growth = run_length_probs * pred * (1 - hazard)
|
||||
cp = (run_length_probs * pred * hazard).sum()
|
||||
new = np.concatenate([[cp], growth])
|
||||
return new / new.sum()
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| 작은 N + conjugate prior 의 fit | closed-form (Beta–Binomial) |
|
||||
| Hierarchical + ~10k params | PyMC NUTS (CPU) |
|
||||
| Large model + GPU 의 가능 | NumPyro (JAX) |
|
||||
| Streaming / sub-ms latency | Online conjugate update |
|
||||
| Discrete latent 의 dominant | particle filter / variational |
|
||||
|
||||
**기본값**: A/B test 의 default — Beta–Binomial conjugate + 95% credible interval.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Bayes-Theorem]]
|
||||
- 변형: [[Belief-Revision]] · [[Inference-Coupled Persistence]]
|
||||
- 응용: [[Item-Item-Collaborative-Filtering]] · [[Statistical-Analysis]]
|
||||
- Adjacent: [[몬테카를로 시뮬레이션]] · [[Multi-agent-System]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: A/B early-stopping decision, sensor fusion, parameter uncertainty 의 explicit propagation.
|
||||
**언제 X**: data 의 abundant + flat likelihood 의 dominant 인 경우 — frequentist MLE 의 sufficient.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Improper prior 의 use**: posterior 의 not normalize 의 가능 — proper prior 의 verify.
|
||||
- **Prior 의 sneaking strong assumption**: subjective prior 의 sensitivity analysis 의 필수.
|
||||
- **Peeking 의 misinterpretation**: Bayesian posterior 의 frequentist p-value 의 X — separate calibration.
|
||||
- **MCMC convergence 의 무시**: R-hat > 1.01, ESS < 400 의 즉시 의 reject.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Gelman et al. *Bayesian Data Analysis* 3rd, McElreath *Statistical Rethinking* 2nd).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — full Bayesian updating with PyMC 5, NumPyro, online BOCPD |
|
||||
|
||||
Reference in New Issue
Block a user