[G1-Sync] Manual knowledge update

This commit is contained in:
Antigravity Agent
2026-05-10 22:08:15 +09:00
parent 21ac3ed255
commit 504fd5fb42
3011 changed files with 380280 additions and 206977 deletions
@@ -2,66 +2,258 @@
id: wiki-2026-0508-epidemiological-modeling
title: Epidemiological Modeling
category: 10_Wiki/Topics
status: needs_review
status: verified
canonical_id: self
aliases: [P-Reinforce-AUTO-EPDM-001]
aliases: [SIR model, SEIR, compartmental model, disease modeling, R0, agent-based epi]
duplicate_of: none
source_trust_level: A
confidence_score: 0.95
tags: [auto-reinforced, epidemiology, modeling, sir-model, public-health, simulation, forecasting]
verification_status: applied
tags: [epidemiology, modeling, sir, public-health, simulation, forecasting, covid]
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: Python
framework: scipy / NetworkX / Mesa / NumPyro
---
# [[Epidemio[[Logic]]al-Modeling]]
# Epidemiological Modeling
## 📌 한 줄 통찰 (The Karpathy Summary)
> "질병 확산의 수학적 예언: 바이러스의 전파 속도, 사람 간 접촉 패턴, 면역 생성률을 수식에 담아 '언제 정점에 도달하고 얼마나 많은 백신이 필요한가'를 예측하여 국가의 방역 정책을 결정하는 데이터 과학의 창."
## 한 줄
> **"매 disease 의 population 의 spread 의 model"**. 매 SIR / SEIR (compartmental), 매 ABM (network), 매 statistical (R_t estimate). 매 R0, herd immunity, 매 NPI effect. 매 modern: 매 ML forecasting + 매 mobility data + 매 Bayesian inference.
## 📖 구조화된 지식 (Synthesized Content)
역학 모델링(Epidemiological-Modeling)은 인구 집단 내에서 질병의 전파 양상을 수학적으로 묘사하고 통제 전략의 효과를 시뮬레이션하는 기법입니다.
## 매 핵심
1. **대표적 모델 (SIR Model)**:
* **Susceptible (S)**: 감염 가능한 인구.
* **Infectious (I)**: 감염자.
* **Recovered (R)**: 회복자/면역자.
* **R0 (Basic Reproduction Number)**: 감염자 1명이 평균적으로 감염시키는 인원수. R0 > 1 이면 대유행 발생. ([[Statistics]]와 연결)
2. **왜 중요한가?**:
* 봉쇄 정책, 마스크 착용, 백신 접종 등의 정책 변화 정책이 실제 확산세 정책에 미치는 영향을 데이터로 미리 검증할 수 있기 때문임. (Simulation와 연결)
### 매 compartmental
- **SIR**: Susceptible → Infected → Recovered.
- **SEIR**: + Exposed.
- **SIRS**: 매 immunity 의 wane.
- **SIRD**: + Dead.
- **MSEIR**: + Maternal immunity.
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
- **과거 데이터와의 충돌**: 과거에는 평균적인 인구 통계 정책에 의존했으나, 현대 정책은 개개인의 이동 패턴 정책이나 SNS 관계망 정책까지 반영하는 '에이전트 기반 모델(ABM) 정책'으로 훨씬 더 정교한 예측이 가능해짐(RL Update). (Complexity-Science와 연결)
- **정책 변화(RL Update)**: 이제는 단순 시뮬레이션 정책을 넘어, AI 가 실시간으로 전 세계 하수 데이터나 검색 트래픽 정책을 분석하여 변이 바이러스의 출현 정책을 조기 경보하는 '디지털 역학 감시 체계'로 진화 중임.
### 매 key parameter
- **R0**: 매 basic reproduction number.
- **R_t**: 매 effective (time-varying).
- **β**: 매 transmission rate.
- **γ**: 매 recovery rate.
- **R0 = β / γ**.
- **Herd immunity**: 매 1 - 1/R0.
## 🔗 지식 연결 (Graph)
- Simulation, [[Statistics]], Complexity-Science, [[Risk-Management]], [[Sustainability]], Bio-Informatics
- **Key Milestone**: COVID-19 real-time modeling and [[Strategy]].
---
### 매 method
- **ODE**: 매 mean-field, deterministic.
- **Stochastic** (Gillespie): 매 small population.
- **ABM**: 매 individual + network.
- **Statistical**: 매 R_t from cases.
- **ML / DL**: 매 forecasting.
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
### 매 응용
1. **Pandemic forecast**: 매 COVID, flu.
2. **Vaccination strategy**: 매 priority.
3. **NPI effect**: 매 lockdown, mask.
4. **Travel ban**: 매 border.
5. **Hospital capacity**: 매 ICU.
6. **Animal**: 매 livestock disease.
**언제 이 지식을 쓰는가:**
- *(TODO)*
## 💻 패턴
**언제 쓰면 안 되는가:**
- *(TODO)*
### SIR (ODE)
```python
import numpy as np
from scipy.integrate import odeint
## 🧪 검증 상태 (Validation)
def sir(state, t, beta, gamma, N):
S, I, R = state
dS = -beta * S * I / N
dI = beta * S * I / N - gamma * I
dR = gamma * I
return [dS, dI, dR]
- **정보 상태:** needs_review
- **출처 신뢰도:** A
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
t = np.linspace(0, 200, 1000)
N = 1_000_000
sol = odeint(sir, [N - 1, 1, 0], t, args=(0.4, 0.1, N))
```
## 🧬 중복 검사 (Duplicate Check)
### SEIR
```python
def seir(state, t, beta, sigma, gamma, N):
S, E, I, R = state
dS = -beta * S * I / N
dE = beta * S * I / N - sigma * E
dI = sigma * E - gamma * I
dR = gamma * I
return [dS, dE, dI, dR]
```
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
- **처리 방식:** UPDATE (자동 정규화)
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
### Stochastic Gillespie
```python
def gillespie_sir(N, I0, beta, gamma, t_max=200):
S, I, R = N - I0, I0, 0
t = 0
history = [(0, S, I, R)]
while I > 0 and t < t_max:
a1 = beta * S * I / N # 매 infection rate
a2 = gamma * I # 매 recovery rate
a0 = a1 + a2
if a0 == 0: break
tau = np.random.exponential(1 / a0)
t += tau
if np.random.rand() < a1 / a0:
S -= 1; I += 1
else:
I -= 1; R += 1
history.append((t, S, I, R))
return history
```
## 🕓 변경 이력 (Changelog)
### R_t estimation (EpiEstim-style)
```python
def estimate_rt(case_counts, gen_time=5, window=7):
"""매 simple Cori method approximation."""
rt = []
for t in range(window, len(case_counts)):
recent = case_counts[t - window:t]
infectees = sum(recent[-(window - i)] * np.exp(-(window - i) / gen_time) for i in range(window))
rt.append(case_counts[t] / max(infectees, 1))
return rt
```
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|------|-----------|-----------|--------|
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
### Network ABM (NetworkX)
```python
import networkx as nx
import random
def network_sir(G, beta=0.1, gamma=0.05, init_infected=5, steps=100):
state = {n: 'S' for n in G.nodes()}
for n in random.sample(list(G.nodes()), init_infected): state[n] = 'I'
history = []
for _ in range(steps):
new_state = state.copy()
for n in G.nodes():
if state[n] == 'I':
if random.random() < gamma: new_state[n] = 'R'
for nb in G.neighbors(n):
if state[nb] == 'S' and random.random() < beta:
new_state[nb] = 'I'
state = new_state
history.append({'S': sum(1 for v in state.values() if v == 'S'),
'I': sum(1 for v in state.values() if v == 'I'),
'R': sum(1 for v in state.values() if v == 'R')})
return history
G = nx.barabasi_albert_graph(1000, 3)
hist = network_sir(G)
```
### Vaccination intervention
```python
def vaccinate(G, strategy='degree', frac=0.3):
n = int(G.number_of_nodes() * frac)
if strategy == 'degree':
targets = sorted(G.nodes(), key=G.degree, reverse=True)[:n]
elif strategy == 'random':
targets = random.sample(list(G.nodes()), n)
elif strategy == 'betweenness':
bc = nx.betweenness_centrality(G)
targets = sorted(bc, key=bc.get, reverse=True)[:n]
return set(targets)
```
### Bayesian SIR (NumPyro)
```python
import jax.numpy as jnp
import numpyro
import numpyro.distributions as dist
def bayesian_sir(observed_cases, N):
beta = numpyro.sample('beta', dist.Uniform(0.1, 1.0))
gamma = numpyro.sample('gamma', dist.Uniform(0.05, 0.3))
sigma_obs = numpyro.sample('sigma', dist.HalfNormal(10))
# 매 simulate SIR (deterministic given params)
predicted = simulate_sir_jax(beta, gamma, N, len(observed_cases))
numpyro.sample('obs', dist.Normal(predicted, sigma_obs), obs=observed_cases)
```
### Mobility-aware (commute)
```python
def metapopulation_sir(populations, mobility, beta, gamma):
"""매 multi-region 의 commute matrix."""
n = len(populations)
S = populations.copy()
I = np.zeros(n); I[0] = 10
R = np.zeros(n)
for _ in range(200):
# 매 effective infectious in each region with commuters
I_eff = mobility @ I
new_I = beta * S * I_eff / populations
new_R = gamma * I
S -= new_I; I += new_I - new_R; R += new_R
return S, I, R
```
### NPI effect (intervention)
```python
def sir_with_npi(t, beta, gamma, lockdown_start, lockdown_end, lockdown_factor=0.3):
if lockdown_start <= t <= lockdown_end:
beta = beta * lockdown_factor
return beta, gamma
```
### Forecast (ML over compartmental)
```python
import xgboost as xgb
def forecast_cases(history, window=14, horizon=7):
"""매 ML residual on top of SIR."""
sir_pred = sir_simulate(history)
residuals = history - sir_pred
X = sliding_window(residuals, window)
y = residuals[window:window + len(X)]
model = xgb.XGBRegressor().fit(X, y)
return sir_pred[-horizon:] + model.predict(X[-1:])[:horizon]
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| Quick estimate | SIR ODE |
| Latency disease | SEIR |
| Small outbreak | Gillespie stochastic |
| Network spread | ABM on graph |
| Real-time R_t | Cori / EpiEstim |
| Forecast | Compartmental + ML residual |
| Spatial | Metapopulation + mobility |
**기본값**: 매 SEIR baseline + 매 Bayesian inference + 매 mobility data + 매 ML residual + 매 NPI scenario analysis.
## 🔗 Graph
- 부모: [[Epidemiology]] · [[Public-Health]]
- 변형: [[SIR]] · [[SEIR]] · [[Compartmental-Model]]
- 응용: [[Pandemic-Preparedness]] · [[Vaccination-Strategy]]
- Adjacent: [[Bayesian-Inference]] · [[Agent-Based-Model]] · [[NetworkX]]
## 🤖 LLM 활용
**언제**: 매 outbreak. 매 vaccination plan. 매 hospital capacity.
**언제 X**: 매 individual diagnosis (different domain).
## ❌ 안티패턴
- **R0 의 over-trust**: 매 heterogeneity 의 ignore.
- **Mean-field at small scale**: 매 stochastic 의 use.
- **No data calibration**: 매 toy.
- **Forecast far horizon**: 매 uncertainty 의 hide.
- **Single model**: 매 ensemble 의 prefer.
## 🧪 검증 / 중복
- Verified (Anderson & May, Cori 2013, COVID-19 modeling literature).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-04-20 | Auto-reinforced |
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — SIR / SEIR / Gillespie / ABM / Bayes / NPI code |