[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,63 +2,156 @@
id: wiki-2026-0508-statistical-power
title: Statistical Power
category: 10_Wiki/Topics
status: needs_review
status: verified
canonical_id: self
aliases: [MATH-STAT-POWER-001]
aliases: [Power-Analysis, 1-beta]
duplicate_of: none
source_trust_level: A
confidence_score: 1.0
tags: [math, Statistics, statistical-power, type-2-error, sample-size, effect-size, data-Analysis]
confidence_score: 0.92
verification_status: applied
tags: [statistics, power, hypothesis-testing, ab-testing, sample-size]
raw_sources: []
last_reinforced: 2026-04-26
last_reinforced: 2026-05-10
github_commit: pending
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
tech_stack:
language: python
framework: statsmodels-scipy
---
# Statistical Power (통계적 검정력)
# Statistical Power
## 📌 한 줄 통찰 (The Karpathy Summary)
> "진실이 존재할 때 이를 확실히 감지해낼 확률을 확보하여, 귀한 통찰을 '우연'으로 치부해버리는 과오(Type II Error)를 방지하라" — 귀무가설이 실제로 거짓일 때 이를 올바르게 기각할 확률 ($1 - \beta$).
## 한 줄
> **"매 effect 가 있을 때 매 detect 의 확률 = 1 β"**. Power 의 true positive rate — sample size, effect size, α, variance 의 함수. 1928 Neyman-Pearson 에서 등장 — 2026 A/B test, clinical trial, 모든 hypothesis test 의 design 의 핵심.
## 📖 구조화된 지식 (Synthesized Content)
- **추출된 패턴:** "Sensitivity [[Optimization|Optimization]] and Error Minimization" — 실험 설계 단계에서 표본 크기(Sample Size)와 효과 크기(Effect Size)를 조절하여, 실제 존재하는 차이를 놓치지 않고 포착할 수 있는 충분한 통계적 '시력'을 확보하는 패턴.
- **검정력에 영향을 주는 4대 요소:**
- **Sample Size ($n$):** 표본이 많을수록 노이즈가 줄어들어 검정력이 높아짐.
- **Effect Size ($d$):** 확인하려는 차이가 클수록 발견하기 쉬움.
- **Significance Level ($\alpha$):** 1종 오류 허용 범위가 넓을수록 검정력은 높아짐 (Trade-off 관계).
- **Variance ($\sigma^2$):** 데이터 자체의 변동성이 작을수록 차이를 선명히 파악 가능.
- **의의:** 실험의 '성공 가능성'을 미리 계산(Power Analysis)하게 함으로써, 자원 낭비를 막고 과학적 결론의 신뢰도를 높이는 핵심 장치.
## 매 핵심
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
- **과거 데이터와의 충돌:** 단순히 P-value에만 집착하던 관행에서 벗어나, 이제는 "실험 결과가 유의미하지 않게 나왔을 때, 그것이 진짜 효과가 없어서인지 아니면 검정력이 부족해서였는지"를 반드시 따져보는 것이 현대 데이터 분석의 윤리적 가이드라인이 됨.
- **정책 변화:** Antigravity 프로젝트는 에이전트의 마이너 업데이트에 대한 A/B 테스트 설계 시, 최소 80% 이상의 검정력을 확보할 수 있는 표본 크기를 사전에 산출하여 실험의 유효성을 담보함.
### 매 4 quantities (lock 3, solve 1)
- **n** — sample size.
- **α** — Type I error rate (false positive), 보통 0.05.
- **β** — Type II error rate (false negative); **power = 1 β**, 보통 0.8.
- **effect size** — Cohen's d (means), Cohen's h (props), r (correlation), f² (regression).
## 🔗 지식 연결 (Graph)
- [[Statistical-Hypothesis-Testing|Statistical-Hypothesis-Testing]], [[Standard-Deviation-and-Variance|Standard-Deviation-and-Variance]], [[Performance-Metrics-in-AI|Performance-Metrics-in-AI]], [[Sampling-Techniques|Sampling-Techniques]]
- **Raw Source:** 10_Wiki/Topics/AI/Statistical-Power.md
### 매 effect size 의 convention (Cohen)
- d = 0.2 (small), 0.5 (medium), 0.8 (large) — for two-sample t-test.
- 매 domain-specific minimum detectable effect (MDE) 의 정의 의 우선 — Cohen 의 default 의 X.
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
### 매 sample size 공식 (two-sample t-test)
- n_per_group ≈ 2·(z_{1-α/2} + z_{1-β})² · σ² / Δ²
- α=0.05, power=0.8, Δ=0.5σ (medium d) → n ≈ 64/group.
**언제 이 지식을 쓰는가:**
- *(TODO)*
### 매 응용
1. A/B test design — pre-experiment sample-size calc.
2. Clinical trial — FDA mandate.
3. Replication crisis — underpowered studies → false discovery.
4. Sequential testing — α-spending for early stopping.
**언제 쓰면 안 되는가:**
- *(TODO)*
## 💻 패턴
## 🧪 검증 상태 (Validation)
### 1. statsmodels — t-test power
```python
from statsmodels.stats.power import TTestIndPower
analysis = TTestIndPower()
n = analysis.solve_power(effect_size=0.5, alpha=0.05, power=0.8, ratio=1.0)
# n ≈ 63.77 per group
```
- **정보 상태:** needs_review
- **출처 신뢰도:** A
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
### 2. Proportion (A/B test) sample size
```python
from statsmodels.stats.proportion import proportion_effectsize
from statsmodels.stats.power import NormalIndPower
es = proportion_effectsize(0.10, 0.12) # baseline 10%, MDE 12%
n = NormalIndPower().solve_power(effect_size=es, alpha=0.05, power=0.8)
# 매 conversion uplift 2pp → ~3800 / arm
```
## 🧬 중복 검사 (Duplicate Check)
### 3. Power curve (visualize tradeoff)
```python
import numpy as np
import matplotlib.pyplot as plt
ns = np.arange(20, 500, 10)
powers = [analysis.solve_power(effect_size=0.3, nobs1=n, alpha=0.05) for n in ns]
plt.plot(ns, powers); plt.axhline(0.8, color="r")
```
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
- **처리 방식:** UPDATE (자동 정규화)
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
### 4. Simulation-based (custom test, complex design)
```python
import numpy as np
def simulate_power(n, effect, sigma, alpha=0.05, B=10000):
rejects = 0
for _ in range(B):
a = np.random.normal(0, sigma, n)
b = np.random.normal(effect, sigma, n)
t = (b.mean() - a.mean()) / np.sqrt(2*sigma**2/n)
if abs(t) > 1.96:
rejects += 1
return rejects / B
```
## 🕓 변경 이력 (Changelog)
### 5. MDE given fixed n (post-hoc planning)
```python
mde = analysis.solve_power(nobs1=1000, alpha=0.05, power=0.8)
# 매 n=1000 에서 detect 가능한 minimum d
```
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|------|-----------|-----------|--------|
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
### 6. Bonferroni-corrected power (multiple tests)
```python
k = 10 # 매 10 hypotheses
adjusted_alpha = 0.05 / k
n_corrected = analysis.solve_power(effect_size=0.5, alpha=adjusted_alpha, power=0.8)
```
### 7. Sequential / group-sequential (early stopping)
```python
# 매 O'Brien-Fleming spending function 의 사용
# 매 이미 누적 α 를 나눠서 spend → 매 final n 의 약간 증가
from statsmodels.stats.proportion import proportions_ztest # for fixed test
# Group-sequential: see `gsDesign` in R or `confseq` in Python (2026)
```
### 8. Cluster-randomized (intra-class correlation)
```python
# 매 design effect = 1 + (m-1)·ρ
# 매 effective sample = n / DE
icc = 0.05; m = 30 # cluster size
DE = 1 + (m-1)*icc # ≈ 2.45
n_effective = 1000 / DE
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| Mean comparison | TTestIndPower (Cohen's d) |
| Proportion (CTR, conversion) | NormalIndPower |
| Complex design / non-standard test | Simulation |
| Multiple testing | Bonferroni / FDR adjusted α |
| Early-stopping | Group-sequential / α-spending |
| Cluster trial | Inflate n by design effect |
**기본값**: α=0.05, power=0.8, MDE 의 domain-driven 정의 → statsmodels solve_power.
## 🔗 Graph
- 부모: [[Statistics]] · [[Probability Theory]]
- 변형: [[Sampling-Techniques]]
- 응용: [[Regression-Analysis-Foundations]] · [[Decision Theory]]
- Adjacent: [[Standard-Deviation-and-Variance]] · [[Multivariate-Analysis]]
## 🤖 LLM 활용
**언제**: explaining tradeoffs (n vs MDE vs power), interpreting power-analysis result, recommending design.
**언제 X**: 매 numerical solve — statsmodels / G*Power 의 사용.
## ❌ 안티패턴
- **Post-hoc power on observed effect**: 매 always ≈ 50% near significance — 매 meaningless. 매 MDE 의 reporting 의 사용.
- **Underpowered + p-hack**: small n + multiple comparisons → false-positive 의 폭증.
- **Ignoring variance assumption**: σ 의 estimate 의 잘못 → n calc 의 wrong.
- **Power=0.5 acceptable**: 매 0.8 minimum (medical 0.9) — 매 50% 의 coin flip.
- **One-sided test for convenience**: 매 effect direction 의 진짜 사전 hypothesis 면 OK, 매 fishing 면 X.
## 🧪 검증 / 중복
- Verified (Cohen 1988 *Statistical Power Analysis*, statsmodels docs, ICH E9 guideline).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — power formulas, statsmodels patterns, A/B test design. |