Files
2nd/10_Wiki/Topics/Domain_General/From_Other/Bayesian-Updating.md
T
Antigravity Agent c24165b8bc refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게
[공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류.
문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인).

- Topic_Programming → Domain_Programming (내부 구조 보존)
- Topic_Graphic → Domain_Design
- Topic_Business → Domain_Product
- Topic_General → Domain_General
- _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning),
  Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing)
- 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서)
- 빈 폴더 정리 (memory/procedures)
- 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 11:05:56 +09:00

5.3 KiB
Raw Blame History

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-bayesian-updating Bayesian Updating 10_Wiki/Topics verified self
Bayesian Inference
Posterior Update
Belief Updating
none A 0.95 applied
statistics
inference
probability
ml
decision-theory
2026-05-10 pending
language framework
Python PyMC / NumPyro

Bayesian Updating

매 한 줄

"매 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.

매 핵심

매 공식

  • 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)

매 conjugate priors

  • BetaBinomial (CTR, conversion rate)
  • GammaPoisson (event counts, arrival rate)
  • NormalNormal (sensor fusion, A/B continuous metric)
  • DirichletMultinomial (categorical preferences)

매 응용

  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).

💻 패턴

BetaBinomial conjugate (CTR)

from scipy import stats
import numpy as np

# Prior: Beta(1, 1) = uniform
alpha, beta = 1.0, 1.0

# Observe: 73 clicks out of 1000 impressions
clicks, impressions = 73, 1000
alpha_post = alpha + clicks
beta_post  = beta + (impressions - clicks)

posterior = stats.beta(alpha_post, beta_post)
print(f"Posterior mean CTR: {posterior.mean():.4f}")
print(f"95% credible interval: {posterior.interval(0.95)}")

Sequential update (online)

def online_beta_update(alpha, beta, click: bool):
    return (alpha + click, beta + (1 - click))

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())

PyMC 5 hierarchical

import pymc as pm
import numpy as np

variants = ["A", "B", "C"]
clicks = np.array([73, 91, 82])
impressions = np.array([1000, 1010, 990])

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)

pm.summary(idata, var_names=["theta"])

NumPyro NUTS (GPU-accelerated, JAX)

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

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 (BetaBinomial)
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 — BetaBinomial conjugate + 95% credible interval.

🔗 Graph

🤖 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