[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,90 +2,155 @@
id: wiki-2026-0508-inferential-statistics
title: Inferential Statistics
category: 10_Wiki/Topics
status: needs_review
status: verified
canonical_id: self
aliases: [P-Reinforce-AUTO-INST-001]
aliases: [Statistical Inference, Hypothesis Testing, Confidence Intervals]
duplicate_of: none
source_trust_level: A
confidence_score: 0.94
tags: [auto-reinforced, inferential-Statistics, statistics, data-Analysis, Hypothesis-Testing, sampling]
confidence_score: 0.92
verification_status: applied
tags: [statistics, inference, hypothesis-testing, ab-testing, sre]
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
---
# [[Inferential-Statistics|Inferential-Statistics]]
# Inferential Statistics
## 📌 한 줄 통찰 (The Karpathy Summary)
> "부분으로 전체를 꿰뚫기: 일부 표본(Sample)에서 나타난 특징을 바탕으로, 우리가 직접 다 볼 수 없는 거대한 전체(Population)속성을 수학적으로 추론하고 그 결론이 얼마나 믿을만한지 확률로 증명하는 지적 예측술."
## 한 줄
> **"매 sample → population parameter 의 추정 + uncertainty 의 quantify"**. 매 1900s Fisher, Neyman, Pearson 의 frequentist framework, 매 2026 A/B test, SRE alerting, ML evaluation backbone — Bayesian + bootstrap 의 modern hybrid 가 default.
## 📖 구조화된 지식 (Synthesized Content)
추론 통계학(Inferential-Statistics)은 데이터 표본을 분석하여 모집단에 대한 결론을 도출하는 방법론입니다.
## 매 핵심
1. **두 기둥**:
* **Estimation (추정)**: 표본을 통해 모집단의 평균이나 비율이 특정 범위 안에 있을 것이라 예측.
* **Hypothesis [[Testing|Testing]] (가설 검정)**: "이 약이 효과가 있는가?"와 같은 주장이 통계적으로 의미가 있는지(p-value) 판단.
2. **왜 중요한가?**:
* 모든 실험과 데이터 분석의 신뢰성을 결정하는 '판사' 역할을 수행함. ([[Inductive-Reasoning|Inductive-Reasoning]]의 수학적 도구)
### 매 Frequentist vs Bayesian
- **Frequentist**: parameter fixed, data random. p-value, CI.
- **Bayesian**: parameter random (prior), data fixed. Posterior, credible interval.
- **Bootstrap**: distribution-free, resample n→inf 시뮬레이션.
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
- **과거 데이터와의 충돌**: 과거에는 작은 표본으로 거대 집단을 설명하려는 '희소 데이터 정책'이 주류였으나, 현대 정책은 방대한 빅데이터 정책 하에서도 '상관관계와 인과관계 정책'을 엄격히 구분하고 변수 간의 복잡한 영향을 파악하는 데 집중함(RL Update).
- **정책 변화(RL Update)**: 단순히 p-value 수치에만 목매는 정책(P-hacking)을 지양하고, 모델의 불확실성을 더 정교하게 다루는 '베이지안 추론 통계 정책'으로의 전환 정책이 가속화되고 있음. (Inductive-[[Reasoning|Reasoning]]와 연결)
### 매 Test 분류
- **Parametric**: t-test, ANOVA, Z-test (assumes normal).
- **Non-parametric**: Mann-Whitney U, Kruskal-Wallis, permutation.
- **Sequential**: Always Valid Inference, mSPRT (peek-safe).
## 🔗 지식 연결 (Graph)
- [[Inductive-Reasoning|Inductive-Reasoning]], [[Analysis|Analysis]], [[Data Cleaning Algorithms|Data Cleaning Algorithms]], [[Decision Theory|Decision Theory]], [[Epistemology|Epistemology]]
- **Modern Tech/Tools**: R, Python (SciPy), Bayesian A/B testing, Confidence intervals.
---
### 매 응용
1. A/B test: conversion lift 측정.
2. SRE: SLO breach 의 statistical significance.
3. ML: model A vs B 의 holdout 비교.
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
## 💻 패턴
**언제 이 지식을 쓰는가:**
- *(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
### Two-sample t-test
```python
import scipy.stats as st
control = [12, 14, 11, 13, 12, 15, 13]
treat = [16, 18, 15, 17, 19, 16, 18]
res = st.ttest_ind(control, treat, equal_var=False)
print(f"t={res.statistic:.3f} p={res.pvalue:.4f}")
ci = res.confidence_interval(0.95)
print(f"95% CI: [{ci.low:.2f}, {ci.high:.2f}]")
```
## 🤔 의사결정 기준 (Decision Criteria)
### Bootstrap CI
```python
import numpy as np
def bootstrap_mean_ci(x, n=10_000, alpha=0.05):
rng = np.random.default_rng(42)
boots = rng.choice(x, size=(n, len(x)), replace=True).mean(axis=1)
return np.quantile(boots, [alpha/2, 1-alpha/2])
**선택 A를 써야 할 때:**
- *(TODO)*
ci = bootstrap_mean_ci(np.array(control))
print(f"Bootstrap 95% CI: {ci}")
```
**선택 B를 써야 할 때:**
- *(TODO)*
### Sample size calculation (power)
```python
from statsmodels.stats.power import TTestIndPower
analysis = TTestIndPower()
n = analysis.solve_power(effect_size=0.3, power=0.8, alpha=0.05)
print(f"매 group 당 n = {int(np.ceil(n))}")
```
**기본값:**
> *(TODO)*
### Sequential test (mSPRT, peek-safe)
```python
import numpy as np
def msprt_log_likelihood(x, mu0=0, sigma=1, theta=0.1):
n = len(x); xbar = np.mean(x); v = sigma**2
tau2 = theta**2
log_bf = 0.5*np.log(v/(v+n*tau2)) + (n**2 * (xbar-mu0)**2 * tau2) / (2*v*(v+n*tau2))
return log_bf # > log(1/alpha) 매 reject H0
```
## ❌ 안티패턴 (Anti-Patterns)
### Bayesian A/B (PyMC)
```python
import pymc as pm
with pm.Model() as m:
p_a = pm.Beta("p_a", 1, 1)
p_b = pm.Beta("p_b", 1, 1)
pm.Binomial("y_a", n=10_000, p=p_a, observed=520)
pm.Binomial("y_b", n=10_000, p=p_b, observed=580)
diff = pm.Deterministic("diff", p_b - p_a)
idata = pm.sample(2000, chains=4, random_seed=42)
print(f"P(B > A) = {(idata.posterior['diff'] > 0).mean().item():.3f}")
```
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
### Permutation test
```python
def permutation_test(a, b, n=10_000):
diff_obs = np.mean(a) - np.mean(b)
pool = np.concatenate([a, b])
rng = np.random.default_rng(0)
diffs = []
for _ in range(n):
rng.shuffle(pool)
diffs.append(np.mean(pool[:len(a)]) - np.mean(pool[len(a):]))
return np.mean(np.abs(diffs) >= abs(diff_obs))
```
### SRE: Welch's test on latency p99
```python
# 매 deploy 전후 latency p99 비교
from scipy.stats import ttest_ind
before_p99 = np.array([124, 130, 128, 132, 125]) # ms
after_p99 = np.array([142, 138, 145, 140, 144])
t, p = ttest_ind(before_p99, after_p99, equal_var=False)
if p < 0.01: print("매 regression detected — rollback")
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| Fixed-N A/B | t-test or chi-squared |
| Continuous monitoring | mSPRT or always-valid CI |
| Small N, non-normal | Bootstrap or permutation |
| Multi-arm + prior | Bayesian (Beta-Binomial) |
**기본값**: Bootstrap CI + sequential test 의 production A/B.
## 🔗 Graph
- 부모: [[Statistics & Data Analysis]] · [[Probability Theory]]
- 변형: [[Bayesian Inference]] · [[Bootstrap]] · [[Permutation Test]]
- 응용: [[A/B Testing]] · [[SRE]] · [[Anomaly-Detection]]
- Adjacent: [[Type 1 vs Type 2 Errors]] · [[Power Analysis]]
## 🤖 LLM 활용
**언제**: test 선택 의 advice (data shape → test type), 의 result interpretation.
**언제 X**: 매 multiple-comparison correction 매 자동화 X — domain knowledge 필요.
## ❌ 안티패턴
- **p-hacking**: 매 multiple test 후 cherry-pick.
- **Peeking**: fixed-N test 의 매 day 확인 → α inflation.
- **Single point**: CI 매 보고 안하고 mean 만.
- **N=∞ → significance ≠ effect size**: Cohen's d 도 같이.
## 🧪 검증 / 중복
- Verified (Casella & Berger "Statistical Inference", scipy/statsmodels docs).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — frequentist + Bayesian + sequential pattern |