[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,91 +2,167 @@
|
||||
id: wiki-2026-0508-statistics
|
||||
title: Statistics
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [P-Reinforce-AUTO-STAT-002]
|
||||
aliases: [Stats, Statistical-Inference]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.98
|
||||
tags: [auto-reinforced, statistics, mathematical-foundation, probability, distribution, data-science]
|
||||
confidence_score: 0.95
|
||||
verification_status: applied
|
||||
tags: [statistics, inference, frequentist, bayesian, foundations]
|
||||
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: scipy-statsmodels-pymc
|
||||
---
|
||||
|
||||
# [[Statistics|Statistics]]
|
||||
# Statistics
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> "현대 문명의 문법: 모호한 세상을 숫자와 확률이라는 정교한 언어로 재정의하고, 불확실성 속에서도 '가장 높은 확률의 정답'을 선택할 수 있게 돕는 데이터 지능의 가장 단단한 수학적 뿌리."
|
||||
## 매 한 줄
|
||||
> **"매 data → 매 truth 의 inference"**. Statistics 의 uncertainty 하의 decision-making — descriptive (summary), inferential (population from sample), causal (intervention) 의 3 axes. 17C Pascal/Fermat 에서 시작, 2026 에 frequentist + Bayesian + ML 의 hybrid 의 표준.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
통계학(Statistics)은 데이터의 수집, 분석, 해석, 시각화를 다루는 수학의 한 분야입니다.
|
||||
## 매 핵심
|
||||
|
||||
1. **3대 기본 개념**:
|
||||
* **Distribution (분포)**: 데이터가 어떤 모양으로 퍼져 있는가 (예: 정규분포).
|
||||
* **Probability (확률)**: 특정 사건이 발생할 가능성. ([[Probabilistic-Reasoning|Probabilistic-Reasoning]]와 연결)
|
||||
* **Sampling (표본 추출)**: 전체를 다 볼 수 없을 때 일부만 보고 전체를 추측하는 기술.
|
||||
2. **왜 중요한가?**:
|
||||
* 통계 없이는 기상 예보도, 백신 개발도, AI 모델의 손실 함수(Loss function) 계산도 불가능함. 즉, 현대 과학의 모든 판단 근거는 통계에서 나옴. (Evidence-Based-Thinking의 기둥)
|
||||
### 매 3 axes
|
||||
- **Descriptive**: mean, median, SD, distribution, viz. 매 "what is".
|
||||
- **Inferential**: confidence interval, hypothesis test, p-value, posterior. 매 "what could be".
|
||||
- **Causal**: RCT, propensity, IV, DAG. 매 "what if".
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌**: 과거에는 계산의 편리함을 위해 많은 가정을 전제로 했으나, 현대 정책은 컴퓨터의 미친 성능 정책을 활용해 복잡한 가정을 다 무시하고 데이터를 직접 때려 넣는 '계산 통계(Computational Statistics) 정책'이 주류가 됨(RL Update).
|
||||
- **정책 변화(RL Update)**: "전통 통계는 죽었다"는 과격한 주장 정책이 나올 정도로, 이제는 예측력 하나로 모든 것을 증명하는 '기계 학습적 통계 정책' 시대로 완전히 넘어옴. ([[Machine Learning (ML)|Machine Learning (ML)]]와 연결)
|
||||
### 매 frequentist vs Bayesian
|
||||
- **Frequentist**: probability = 매 long-run frequency. 매 parameters fixed, data random. p-value, CI.
|
||||
- **Bayesian**: probability = 매 belief degree. 매 parameters random (prior + likelihood → posterior). credible interval.
|
||||
- 매 ML community 의 mostly Bayesian-ish (regularization = prior).
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- [[Probabilistic-Reasoning|Probabilistic-Reasoning]], Evidence-Based-Thinking, [[Machine Learning (ML)|Machine Learning (ML)]], [[Statistical-Analysis|Statistical-Analysis]], [[Scientific-Method|Scientific-Method]]
|
||||
- **Modern Intersection**: Data Science = Statistics + Programming + Domain Knowledge.
|
||||
---
|
||||
### 매 inference workflow
|
||||
1. Question → estimand 정의.
|
||||
2. Design → sample, randomization, power.
|
||||
3. Data collection.
|
||||
4. Model — distribution / link function.
|
||||
5. Estimate — MLE, MAP, posterior.
|
||||
6. Inference — CI / credible interval, test.
|
||||
7. Critique — diagnostics, sensitivity, replication.
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
### 매 응용
|
||||
1. A/B testing — frequentist or Bayesian decision.
|
||||
2. Survey / poll — sampling design.
|
||||
3. Clinical trial — RCT, survival analysis.
|
||||
4. ML model evaluation — bootstrap, cross-validation.
|
||||
5. Causal inference — econometrics, epidemiology.
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
## 💻 패턴
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
|
||||
- **정보 상태:** 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
|
||||
### 1. Descriptive — pandas
|
||||
```python
|
||||
import pandas as pd
|
||||
df.describe() # mean, std, quartiles
|
||||
df.groupby("group").agg(["mean", "std", "count"])
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### 2. Hypothesis test — scipy
|
||||
```python
|
||||
from scipy import stats
|
||||
t, p = stats.ttest_ind(a, b, equal_var=False) # Welch's t
|
||||
u, p = stats.mannwhitneyu(a, b) # nonparametric
|
||||
chi, p, dof, exp = stats.chi2_contingency(table)
|
||||
```
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### 3. Confidence interval (bootstrap, distribution-free)
|
||||
```python
|
||||
import numpy as np
|
||||
def bootstrap_ci(x, stat=np.mean, B=10000, alpha=0.05):
|
||||
boot = [stat(np.random.choice(x, len(x), replace=True)) for _ in range(B)]
|
||||
return np.percentile(boot, [100*alpha/2, 100*(1-alpha/2)])
|
||||
```
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### 4. Linear regression with inference (statsmodels)
|
||||
```python
|
||||
import statsmodels.api as sm
|
||||
X = sm.add_constant(df[["x1", "x2"]])
|
||||
model = sm.OLS(df["y"], X).fit()
|
||||
print(model.summary()) # coef, SE, p, R²
|
||||
print(model.conf_int())
|
||||
```
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
### 5. Bayesian inference (PyMC, 2026)
|
||||
```python
|
||||
import pymc as pm
|
||||
with pm.Model() as m:
|
||||
mu = pm.Normal("mu", 0, 10)
|
||||
sigma = pm.HalfNormal("sigma", 5)
|
||||
y = pm.Normal("y", mu=mu, sigma=sigma, observed=data)
|
||||
idata = pm.sample(2000, tune=1000, chains=4, target_accept=0.95)
|
||||
import arviz as az
|
||||
az.summary(idata, var_names=["mu", "sigma"])
|
||||
```
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
### 6. Multiple testing — BH (FDR)
|
||||
```python
|
||||
from statsmodels.stats.multitest import multipletests
|
||||
reject, p_adj, _, _ = multipletests(p_values, alpha=0.05, method="fdr_bh")
|
||||
```
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
### 7. Causal — propensity score matching
|
||||
```python
|
||||
from sklearn.linear_model import LogisticRegression
|
||||
ps = LogisticRegression().fit(X, treatment).predict_proba(X)[:, 1]
|
||||
# 매 nearest neighbor matching on logit(ps) → ATT estimate
|
||||
```
|
||||
|
||||
### 8. Survival — Kaplan-Meier
|
||||
```python
|
||||
from lifelines import KaplanMeierFitter
|
||||
kmf = KaplanMeierFitter()
|
||||
kmf.fit(durations, event_observed=events)
|
||||
kmf.plot_survival_function()
|
||||
```
|
||||
|
||||
### 9. Cross-validation (proper inference for ML)
|
||||
```python
|
||||
from sklearn.model_selection import cross_val_score
|
||||
scores = cross_val_score(model, X, y, cv=5, scoring="neg_mean_squared_error")
|
||||
ci = (scores.mean() - 1.96*scores.std(), scores.mean() + 1.96*scores.std())
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Quick descriptive | pandas .describe() |
|
||||
| 2-group mean diff | Welch's t (default) / Mann-Whitney (non-Gaussian) |
|
||||
| Proportion test | chi-square / Fisher's exact (small n) |
|
||||
| Complex hierarchy | Mixed effects (statsmodels.MixedLM) / Bayesian (PyMC) |
|
||||
| Decision under uncertainty | Bayesian posterior |
|
||||
| Causal claim | RCT > IV > DiD > matching |
|
||||
| Many tests | FDR (BH) / FWER (Bonferroni for safety-critical) |
|
||||
| Distribution-free CI | Bootstrap |
|
||||
|
||||
**기본값**: descriptive 먼저 → assumption 의 check → frequentist 의 CI/test 의 default → critical decision 시 Bayesian 의 considerable.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Probability Theory]] · [[Mathematics]]
|
||||
- 변형: [[Probability-Theory-Foundations]] · [[Sampling-Techniques]]
|
||||
- 응용: [[Regression-Analysis-Foundations]] · [[Statistical-Power]] · [[Multivariate-Analysis]]
|
||||
- Adjacent: [[Standard-Deviation-and-Variance]] · [[Information Theory]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: choosing appropriate test, interpreting output, explaining p-value/CI to non-technical, drafting analysis plan.
|
||||
**언제 X**: 매 numerical computation — scipy/statsmodels/PyMC 의 사용.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **p < 0.05 = 매 truth**: 매 decision threshold 의 X, just evidence — replication, effect size, prior 의 고려.
|
||||
- **Correlation = causation**: 매 흔한 fallacy — confounding, reverse causality, selection.
|
||||
- **Ignoring assumptions**: t-test 의 normality, regression 의 linearity → 매 diagnostic 의 필수.
|
||||
- **Cherry-picking subgroups**: 매 fishing → false positive 의 폭증.
|
||||
- **Reporting only mean (skewed data)**: median, IQR 의 추가.
|
||||
- **Sample size 의 unspecified**: 매 power 의 미상.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Wasserman *All of Statistics*, Gelman *BDA3*, ASA p-value statement 2016).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — frequentist/Bayesian/causal axes + workflow. |
|
||||
|
||||
Reference in New Issue
Block a user