Files
2nd/10_Wiki/Topic_Programming/DevOps_and_Security/Inferential-Statistics.md
T
Antigravity Agent 9148c358d0 docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를
Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류.

- 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로
  자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거,
  동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거.
- 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming,
  Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business,
  Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로,
  나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는
  title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백).
  원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지.
- 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서.
- 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는
  지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지.
- Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경.
- 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
2026-07-05 00:33:48 +09:00

5.0 KiB
Raw Blame History

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-inferential-statistics Inferential Statistics 10_Wiki/Topics verified self
Statistical Inference
Hypothesis Testing
Confidence Intervals
none A 0.92 applied
statistics
inference
hypothesis-testing
ab-testing
sre
2026-05-10 pending
language framework
python scipy

Inferential Statistics

매 한 줄

"매 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.

매 핵심

매 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 시뮬레이션.

매 Test 분류

  • Parametric: t-test, ANOVA, Z-test (assumes normal).
  • Non-parametric: Mann-Whitney U, Kruskal-Wallis, permutation.
  • Sequential: Always Valid Inference, mSPRT (peek-safe).

매 응용

  1. A/B test: conversion lift 측정.
  2. SRE: SLO breach 의 statistical significance.
  3. ML: model A vs B 의 holdout 비교.

💻 패턴

Two-sample t-test

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}]")

Bootstrap CI

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])

ci = bootstrap_mean_ci(np.array(control))
print(f"Bootstrap 95% CI: {ci}")

Sample size calculation (power)

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))}")

Sequential test (mSPRT, peek-safe)

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

Bayesian A/B (PyMC)

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}")

Permutation test

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

# 매 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

🤖 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