Files
2nd/10_Wiki/Topic_Programming/Frontend/대수의 법칙(Law of Large Numbers).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

169 lines
5.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
id: wiki-2026-0508-대수의-법칙-law-of-large-numbers
title: 대수의 법칙(Law of Large Numbers)
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [LLN, Law of Large Numbers, 큰 수의 법칙]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [statistics, probability, frontend-analytics, ab-testing]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: typescript
framework: analytics
---
# 대수의 법칙(Law of Large Numbers)
## 매 한 줄
> **"매 sample 수가 커질수록 sample mean 의 expected value 로의 수렴"**. 매 Bernoulli (1713) 의 weak LLN, Kolmogorov (1930) 의 strong LLN. 매 frontend analytics / A/B testing / RUM (Real User Monitoring) 의 통계적 정당성 — 매 sample 적으면 의미 X.
## 매 핵심
### 매 두 형태
- **Weak LLN**: $\bar{X}_n \xrightarrow{P} \mu$ — 매 probability convergence.
- **Strong LLN**: $\bar{X}_n \xrightarrow{a.s.} \mu$ — 매 almost sure convergence.
- 매 둘 다 finite mean μ 가정.
### 매 frontend 함의
- **A/B test sample size**: 매 N=100 의 noise 지배 — 매 N=10,000+ 필요 (effect size 의 함수).
- **Core Web Vitals p75**: 매 RUM 의 "75th percentile" — 매 N>1,000 sessions 권장 (Google).
- **Conversion rate stabilization**: 매 daily flux → weekly average 의 수렴.
- **Error rate monitoring**: 매 small traffic page 의 false alert.
### 매 응용
1. A/B test power analysis (sample size calculator).
2. Web Vitals percentile reliability.
3. Recommendation system click-through rate.
4. Survival analysis of user retention.
## 💻 패턴
### Sample size for A/B test
```typescript
// Two-proportion z-test, 80% power, α=0.05
function abTestSampleSize(
baselineRate: number,
minDetectableEffect: number,
): number {
const p1 = baselineRate;
const p2 = baselineRate + minDetectableEffect;
const pBar = (p1 + p2) / 2;
const z_alpha = 1.96; // two-sided 0.05
const z_beta = 0.84; // power 0.80
const numerator =
Math.pow(z_alpha * Math.sqrt(2 * pBar * (1 - pBar)) +
z_beta * Math.sqrt(p1 * (1 - p1) + p2 * (1 - p2)), 2);
return Math.ceil(numerator / Math.pow(p2 - p1, 2));
}
// Baseline 5% conversion, want to detect +1 percentage point lift
console.log(abTestSampleSize(0.05, 0.01)); // ~3,000 per arm
```
### Running mean (LLN visualizer)
```typescript
function* runningMean(samples: Iterable<number>) {
let n = 0;
let mean = 0;
for (const x of samples) {
n += 1;
mean += (x - mean) / n; // Welford
yield { n, mean };
}
}
// Coin flip (true mean = 0.5)
const flips = Array.from({ length: 10000 }, () => (Math.random() < 0.5 ? 1 : 0));
for (const { n, mean } of runningMean(flips)) {
if (n % 1000 === 0) console.log(`n=${n}, mean=${mean.toFixed(4)}`);
}
// n=1000 mean ≈ 0.49
// n=10000 mean ≈ 0.50 (LLN convergence)
```
### Web Vitals percentile reliability check
```typescript
import { onLCP } from 'web-vitals';
const lcpSamples: number[] = [];
onLCP((metric) => {
lcpSamples.push(metric.value);
if (lcpSamples.length >= 1000) {
const sorted = [...lcpSamples].sort((a, b) => a - b);
const p75 = sorted[Math.floor(sorted.length * 0.75)];
sendBeacon({ p75, n: lcpSamples.length });
}
});
// p75 trustworthy only after N>1,000 (Google CrUX guidance)
```
### Bayesian early-stopping (avoid LLN trap)
```typescript
// Don't peek at A/B test before sample size reached!
function shouldStop(arm: { successes: number; trials: number }, target: number) {
if (arm.trials < target) return false;
// proceed to analysis
return true;
}
```
### Bootstrap confidence interval
```typescript
function bootstrapCI(samples: number[], B = 10000, alpha = 0.05) {
const means: number[] = [];
for (let b = 0; b < B; b++) {
let sum = 0;
for (let i = 0; i < samples.length; i++) {
sum += samples[Math.floor(Math.random() * samples.length)];
}
means.push(sum / samples.length);
}
means.sort((a, b) => a - b);
return [
means[Math.floor(B * (alpha / 2))],
means[Math.floor(B * (1 - alpha / 2))],
];
}
```
## 매 결정 기준
| 상황 | Sample size guideline |
|---|---|
| Web Vitals p75 (Google CrUX) | N > 1,000 sessions per page |
| A/B test (5% baseline, 1pp lift) | ~3,000 per arm |
| Click-through rate stabilization | N > 10,000 impressions |
| Error rate monitoring (rare events) | Apply Poisson, not LLN naively |
**기본값**: 매 결과 보고 전 N≥1,000 — 매 LLN safety zone.
## 🔗 Graph
- 부모: [[Probability Theory]] · [[Statistical Inference]]
- 응용: [[Core Web Vitals Optimization (INP, LCP, CLS)|Core Web Vitals]]
- Adjacent: [[Monte Carlo Methods]]
## 🤖 LLM 활용
**언제**: 매 sample size 결정 / 매 metric 의 reliability 의 statistical 정당화 / 매 small-N false-positive 의 진단.
**언제 X**: 매 비-i.i.d. data (autocorrelated time series) — 매 LLN naive 적용 X. 매 stationarity 확인.
## ❌ 안티패턴
- **Peeking at A/B test**: 매 N=50 에서 "winner" 선언 — 매 LLN 미달 + multiple testing.
- **Rare event LLN**: 매 0.01% conversion → 매 N=1000 의 평균 0 가능. 매 Poisson 필요.
- **Heavy-tail distribution**: 매 Cauchy (no finite mean) — 매 LLN 미적용.
- **Selection bias**: 매 sample 이 random 이 X — 매 N 무관 의 biased estimate.
## 🧪 검증 / 중복
- Verified (Kolmogorov, "Foundations of Probability"; Google web.dev — Web Vitals reporting).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — LLN with frontend analytics applications |