[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,62 +2,152 @@
id: wiki-2026-0508-standard-deviation-and-variance
title: Standard Deviation and Variance
category: 10_Wiki/Topics
status: needs_review
status: verified
canonical_id: self
aliases: [MATH-STAT-VAR-001]
aliases: [SD, Variance, Sigma]
duplicate_of: none
source_trust_level: A
confidence_score: 1.0
tags: [math, Statistics, standard-deviation, variance, dispersion, data-Analysis, normal-distribution]
confidence_score: 0.95
verification_status: applied
tags: [statistics, variance, dispersion, foundations]
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: numpy-scipy
---
# Standard Deviation and Variance (표준 편차 및 분산)
# Standard Deviation and Variance
## 📌 한 줄 통찰 (The Karpathy Summary)
> "평균이라는 중심에서 데이터가 얼마나 멀리 방황하는지 '거리의 평균'으로 측정하여, 집단의 변동성과 불확실성을 수치라는 명확한 잣대로 정의하라" — 데이터의 흩어짐(산포도)을 나타내는 가장 핵심적인 통계 지표.
## 한 줄
> **"매 spread = E[(X-μ)²] 의 sqrt"**. Variance 의 expected squared deviation, SD 의 unit-scale spread. 1894 Pearson 이 명명 — 매 모든 statistics 의 가장 fundamental dispersion measure.
## 📖 구조화된 지식 (Synthesized Content)
- **추출된 패턴:** "Squared Deviation Averaging and Dimensional [[Normalization|Normalization]]" — 개별 데이터와 평균의 차이를 제곱하여 모두 더함으로써 편차의 합이 0이 되는 문제를 해결하고(Variance), 여기에 다시 제곱근을 취해 원본 데이터와 단위를 맞춤으로써 해석력을 확보하는 패턴.
- **핵심 개념:**
- **Variance ($\sigma^2$):** 데이터가 평균에서 떨어진 거리의 제곱 평균. 변동성의 총량.
- **Standard Deviation ($\sigma$):** 분산의 제곱근. 데이터의 평균적인 이탈 거리.
- **68-95-99.7 Rule:** 정규 분포에서 표준 편차의 배수에 따라 데이터가 포함될 확률 정의.
- **의의:** 데이터의 안정성을 평가하고, 이상치(Outlier)를 판별하며, 모델의 예측 오차나 금융 시장의 변동성(Risk)을 측정하는 모든 데이터 과학의 절대적 기초.
## 매 핵심
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
- **과거 데이터와의 충돌:** 평균 중심의 분석이 전부라 믿던 시대에서 벗어나, 이제는 평균이 같더라도 표준 편차가 큰 '두터운 꼬리(Fat Tail)' 데이터가 실전 비즈니스(예: 블랙 스완 사건)에서 훨씬 더 위험하고 중요하다는 인식이 확산됨.
- **정책 변화:** Antigravity 프로젝트는 에이전트의 응답 시간(Latency) 관리 시, 평균값뿐만 아니라 표준 편차를 상시 모니터링하여 서비스 경험의 일관성(Consistency)을 엄격히 관리함.
### 매 정의
- **Variance**: σ² = E[(X μ)²] = E[X²] (E[X])².
- **Standard deviation**: σ = √Var(X) — 매 same unit as X.
- **Sample variance**: s² = Σ(xᵢ x̄)² / (n 1) — 매 Bessel correction (n1) 의 unbiased estimator.
- **Population variance**: σ² = Σ(xᵢ μ)² / N.
## 🔗 지식 연결 (Graph)
- [[Probability-Theory-Foundations|Probability-Theory-Foundations]], [[Outlier-Detection-Techniques|Outlier-Detection-Techniques]], [[Performance-Metrics-in-AI|Performance-Metrics-in-AI]], [[Normalization-Strategies|Normalization-Strategies]]
- **Raw Source:** 10_Wiki/Topics/AI/Standard-Deviation-and-Variance.md
### 매 property
- **Var(aX + b) = a²·Var(X)** — 매 shift invariant, scale 의 square.
- **Var(X + Y) = Var(X) + Var(Y) + 2·Cov(X, Y)** — independent 면 cov=0.
- **SD 의 robust X**: 매 outlier 의 영향 의 큼 — robust alt: MAD (Median Absolute Deviation), IQR.
- **Chebyshev**: P(|X−μ| ≥ kσ) ≤ 1/k² — 매 distribution-free.
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
### 매 응용
1. Risk (finance) — volatility = SD of returns.
2. Quality control — Six Sigma (process σ).
3. Z-score normalization — (x μ) / σ.
4. Confidence interval — μ ± z·(σ/√n).
**언제 이 지식을 쓰는가:**
- *(TODO)*
## 💻 패턴
**언제 쓰면 안 되는가:**
- *(TODO)*
### 1. NumPy — sample vs population
```python
import numpy as np
x = np.array([2, 4, 4, 4, 5, 5, 7, 9])
np.var(x) # 매 population (ddof=0) → 4.0
np.var(x, ddof=1) # 매 sample (Bessel) → 4.571
np.std(x, ddof=1) # 매 2.138
```
## 🧪 검증 상태 (Validation)
### 2. Welford's online algorithm
```python
# 매 streaming, numerically stable, single-pass
def welford_update(state, x):
n, mean, M2 = state
n += 1
delta = x - mean
mean += delta / n
M2 += delta * (x - mean)
return n, mean, M2
- **정보 상태:** needs_review
- **출처 신뢰도:** A
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
n, mean, M2 = 0, 0.0, 0.0
for x in stream:
n, mean, M2 = welford_update((n, mean, M2), x)
var = M2 / (n - 1)
```
## 🧬 중복 검사 (Duplicate Check)
### 3. Z-score normalization
```python
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X) # 매 column-wise (x μ) / σ
```
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
- **처리 방식:** UPDATE (자동 정규화)
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
### 4. Rolling SD (pandas)
```python
import pandas as pd
returns = pd.Series(prices).pct_change()
volatility_30d = returns.rolling(30).std() * np.sqrt(252) # annualized
```
## 🕓 변경 이력 (Changelog)
### 5. Pooled variance (two groups)
```python
def pooled_var(x1, x2):
n1, n2 = len(x1), len(x2)
s1, s2 = np.var(x1, ddof=1), np.var(x2, ddof=1)
return ((n1-1)*s1 + (n2-1)*s2) / (n1 + n2 - 2)
```
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|------|-----------|-----------|--------|
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
### 6. Bias-variance decomposition
```python
# E[(y - ŷ)²] = Bias² + Variance + σ²_noise
# 매 ML model selection 의 핵심
```
### 7. Robust alternatives — MAD
```python
from scipy.stats import median_abs_deviation
mad = median_abs_deviation(x, scale="normal") # ~1.4826 * raw MAD ≈ σ for Gaussian
```
### 8. Two-pass safe variance (numerically)
```python
# Naive E[X²] - E[X]² → 매 catastrophic cancellation 의 위험 (large mean, small var)
# 매 2-pass: μ first, then Σ(x-μ)²
mean = x.sum() / n
var = ((x - mean) ** 2).sum() / (n - 1)
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| Sample (inference) | ddof=1 (n1 division) |
| Population (descriptive) | ddof=0 |
| Streaming / online | Welford |
| Outlier-heavy data | MAD, IQR (not SD) |
| Heavy-tail distribution | Quantile-based (P95/P5) |
| Volatility (finance) | Rolling SD × √(periods/year) |
**기본값**: `np.std(x, ddof=1)` — 매 sample SD, 매 unbiased point estimator.
## 🔗 Graph
- 부모: [[Statistics]] · [[Probability Theory]]
- 변형: [[Mutual-Information]] · [[Information-Entropy]]
- 응용: [[Regression-Analysis-Foundations]] · [[Statistical-Power]]
- Adjacent: [[Sampling-Techniques]] · [[Multivariate-Analysis]]
## 🤖 LLM 활용
**언제**: explanation of spread to non-technical, choosing appropriate measure given distribution.
**언제 X**: 매 numerical computation — `numpy` 의 사용.
## ❌ 안티패턴
- **ddof confusion**: NumPy default `ddof=0` (population) — 매 inference 시 `ddof=1` 의 명시.
- **SD on non-numeric / ordinal**: 매 ordinal scale 의 SD 의 의미 X.
- **Reporting SD without n**: 매 SE = σ/√n 의 더 informative.
- **Catastrophic cancellation**: naive Σx² (Σx)²/n → use Welford or 2-pass.
- **SD assumes Gaussian-like**: 매 power-law 의 SD 의 unstable, 매 quantile 의 사용.
## 🧪 검증 / 중복
- Verified (Knuth TAOCP vol 2, Welford 1962, NIST/SEMATECH stats handbook).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — variance fundamentals, Welford, ddof, robust alt. |