Tech PostsTech Posts
기초와 계량경제학Basics & Econometrics · 01 / 24
01 기초와 계량경제학Basics & Econometrics

중심극한정리는 언제 도착하는가When Does the Central Limit Theorem Actually Arrive?

신뢰구간을 하나 보고할 때마다 우리는 이 정리에 기댑니다. 다만 그게 정말 도착했는지 확인하는 사람은 드뭅니다.Every confidence interval you report leans on this theorem. Almost nobody checks whether it has actually shown up yet.

평균을 계산하고 표준오차를 붙이고 신뢰구간을 보고합니다. 이 세 동작은 모두 중심극한정리가 이미 작동하고 있다는 전제 위에 서 있습니다. 그런데 그 전제를 확인하는 절차는 대개 생략됩니다.

You compute a mean, attach a standard error, report an interval. All three steps assume the Central Limit Theorem has already kicked in. The step that checks whether it has is usually skipped.

정리 자체는 짧습니다. 평균과 분산이 유한한 아무 분포에서나 독립적으로 표본을 뽑아 평균을 냅니다. 표본이 커질수록 그 평균의 분포는 정규분포에 가까워집니다. 원래 분포가 얼마나 정규분포와 동떨어져 있든 상관없습니다.

The theorem itself is short. Draw independent samples from any distribution with finite mean and variance, then average them. As the sample grows, the distribution of that average approaches a normal distribution, no matter how un-normal the thing you sampled from was.

마지막 문장이 이 정리를 쓸모 있게 만듭니다. 고객당 매출이나 배송 소요시간, 보험 청구액의 분포를 아는 경우는 거의 없습니다. 알 필요가 없다는 것이 이 정리의 약속입니다. 필요한 것은 평균의 분포뿐이고 그건 정규분포에 가깝습니다.

That last clause is what makes it useful. You almost never know the distribution of revenue per customer, or delivery time, or claim size. The theorem says you do not need to. You only need the distribution of the average, and that one is approximately normal.

정리가 실제로 약속하는 것What the theorem actually promises

표본평균에 흔히 쓰는 식은 이렇게 생겼습니다.

The familiar statement for a sample mean looks like this.

Z = (X̄ − μ) / (σ / √n) → N(0, 1) as n → ∞
μ는 모평균, σ는 모표준편차, n은 표본 크기입니다.μ is the population mean, σ the population standard deviation, n the sample size.

이 한 줄에는 성격이 다른 세 가지 주장이 섞여 있습니다. 구분해 두면 나중에 헷갈리지 않습니다.

Three separate claims are bundled into that one line. Keeping them apart saves confusion later.

  • 중심. 표본평균의 분포는 모평균 μ를 중심으로 놓입니다. 표본평균은 어떤 n에서도 불편추정량입니다.
  • 퍼짐. 그 분포의 표준편차, 즉 표준오차는 σ/√n입니다. 정밀도는 표본 크기의 제곱근에 비례해 좋아집니다. 관측치를 1,000개에서 4,000개로 늘려야 오차 막대가 절반이 되는 이유입니다.
  • 모양. 분포의 모양이 정규분포로 수렴합니다. 점근적인 부분은 여기뿐이고 사람들이 확인 없이 가정하는 부분도 여기입니다.
  • Centring. The sampling distribution of the mean sits on the population mean μ. The sample mean is unbiased at any n.
  • Scale. Its standard deviation, the standard error, is σ/√n. Precision improves with the square root of sample size, which is why going from 1,000 to 4,000 observations only halves the error bar.
  • Shape. The shape converges to normal. This is the only asymptotic part, and it is the part people assume without checking.

"충분히 크다"는 얼마나 큰가How large is "large enough"?

n ≥ 30이라는 경험칙은 어디서나 반복됩니다. 틀렸다기보다는 조건이 빠져 있습니다. 정직한 답은 이렇습니다. 수렴 속도는 원분포가 얼마나 비대칭인지에 달려 있습니다.

The n >= 30 rule of thumb is repeated everywhere. It is not so much wrong as unconditional. The honest answer is that convergence speed depends on how skewed the parent distribution is.

원분포수렴
정규분포n = 1에서도 정확히 정규분포. 근사가 개입하지 않습니다.
대칭분포빠릅니다. n이 10~25면 대체로 신뢰할 만합니다.
비대칭분포느리고 오차가 한쪽으로 쏠립니다. 구간이 좁아지는 게 아니라 중심에서 밀려납니다.
두꺼운 꼬리매우 느립니다. 분산이 무한하면 아예 수렴하지 않습니다.
Parent distributionConvergence
NormalExactly normal at n = 1. No approximation involved.
SymmetricFast. n of 10-25 is usually trustworthy.
SkewedSlower, and the error is one-sided. Intervals sit off-centre rather than merely being too narrow.
Heavy-tailedVery slow. With infinite variance it never happens at all.

Berry–Esseen 정리는 이 감각에 숫자를 붙여 줍니다. 정규근사의 오차는 ρ/(σ³√n) 정도로 줄어듭니다. 여기서 ρ는 3차 절대적률입니다. 실무적으로 읽으면 이렇습니다. 속도를 늦추는 것은 왜도이고 그 대가는 √n입니다. 왜도가 세 배면 같은 근사 품질에 도달하는 데 표본이 아홉 배 필요합니다.

The Berry-Esseen bound puts numbers on this intuition: the error in the normal approximation shrinks like ρ/(σ³√n), where ρ is the third absolute moment. Read practically: skewness is what slows you down, and it costs you √n. Triple the skewness and you need nine times the sample for the same approximation quality.

수렴을 눈으로 보기Watching it happen

가장 빠른 방법은 표본평균의 분포가 만들어지는 과정을 직접 그려 보는 것입니다. 아래는 지수분포에서 뽑습니다. 오른쪽으로 강하게 치우친, 종 모양과는 거리가 먼 분포입니다.

The fastest way to build intuition is to watch the sampling distribution form. This draws from an exponential distribution, strongly right-skewed and nothing like a bell curve.

python
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import skew

rng = np.random.default_rng(42)
REPLICATIONS = 20_000

fig, axes = plt.subplots(1, 4, figsize=(16, 3.5), sharey=False)

for ax, n in zip(axes, [1, 5, 30, 200]):
    # 20,000 independent samples of size n, each collapsed to its mean
    means = rng.exponential(scale=1.0, size=(REPLICATIONS, n)).mean(axis=1)
    ax.hist(means, bins=60, density=True, alpha=0.75)
    ax.set_title(f"n = {n}   skew = {skew(means):.2f}")
    ax.set_xlabel("sample mean")

plt.tight_layout()
n을 네 단계로 키우면서 표본평균의 분포가 어떻게 변하는지 봅니다.The distribution of the sample mean at four increasing sample sizes.

n = 1이면 지수분포 자체입니다. 0 근처에 몰려 있고 오른쪽으로 긴 꼬리가 붙어 있습니다. n = 5에서 이미 봉우리가 생기고 n = 30이면 종 모양에 가까워지지만 여전히 오른쪽으로 기울어 있습니다. n = 200에서 기울기는 사실상 사라집니다.

At n = 1 you are looking at the exponential itself: a spike near zero with a long right tail. By n = 5 it has a hump. By n = 30 it is broadly bell-shaped but still leans right. By n = 200 the skew is essentially gone.

여기서 추적할 만한 숫자는 표본평균 분포의 왜도입니다. 원분포의 왜도를 √n으로 나눈 값으로 줄어듭니다.

The number worth tracking is the skewness of the sampling distribution, which decays as the parent skewness divided by √n.

python
for n in [1, 5, 30, 200]:
    means = rng.exponential(size=(REPLICATIONS, n)).mean(axis=1)
    print(f"n={n:>4}  skew={skew(means): .3f}  (theory: {2 / n**0.5: .3f})")
n=   1  skew= 1.998  (theory:  2.000)
n=   5  skew= 0.893  (theory:  0.894)
n=  30  skew= 0.365  (theory:  0.365)
n= 200  skew= 0.141  (theory:  0.141)

지수분포의 왜도는 2입니다. √n으로 나누면 시뮬레이션 결과와 정확히 맞습니다. 여기서 "n ≥ 30"보다 훨씬 쓸 만한 규칙이 나옵니다. 데이터의 왜도를 재고, 왜도/√n이 0.2 아래가 되도록 n을 잡으십시오. 지수분포라면 30으로는 모자랍니다. 100 정도는 필요합니다.

The exponential has skewness 2. Divide by √n and you get exactly what the simulation shows. This gives a far better rule than "n >= 30": estimate the skewness of your data and pick n so that skew/√n falls under about 0.2. For the exponential that means n around 100, not 30.

그래서 구간은 정말 덮는가Does the interval actually cover?

모양이 수렴한다는 건 추상적입니다. 실무에서 궁금한 건 명목 95% 구간이 정말로 95%의 경우에 참값을 담느냐입니다. 이건 직접 측정할 수 있습니다.

Convergence in shape is abstract. What you care about operationally is whether a nominal 95% interval really contains the truth 95% of the time. That is directly measurable.

python
from scipy import stats

def coverage(n, replications=20_000, alpha=0.05):
    """Share of nominal 95% t-intervals that contain the true mean."""
    samples = rng.exponential(scale=1.0, size=(replications, n))
    means = samples.mean(axis=1)
    errors = samples.std(axis=1, ddof=1) / n**0.5
    critical = stats.t.ppf(1 - alpha / 2, df=n - 1)
    lower, upper = means - critical * errors, means + critical * errors
    return ((lower < 1.0) & (1.0 < upper)).mean()

for n in [5, 10, 30, 100, 500]:
    print(f"n={n:>4}  coverage={coverage(n):.3f}")
n=   5  coverage=0.868
n=  10  coverage=0.897
n=  30  coverage=0.928
n= 100  coverage=0.943
n= 500  coverage=0.949

정리가 구해 주지 않는 세 경우Where the theorem does not save you

실무에서 자주 부딪히는 순서대로 세 가지입니다.

Three failure modes, in rough order of how often they bite.

독립이 아닐 때Dependence

정리는 독립 표본을 전제합니다. 같은 사용자에게서 반복 측정한 값, 같은 매장의 일별 관측치, 시간이나 그룹 구조가 있는 데이터는 모두 이 전제를 깹니다. 평균은 여전히 불편추정량이지만 σ/√n은 참 표준오차를 과소평가합니다. 때로는 크게 과소평가합니다.

The theorem assumes independent draws. Repeated measurements on the same user, daily observations from the same store, anything with a time or group structure violates it. The mean stays unbiased, but σ/√n understates the true standard error, sometimes badly.

해법은 표본을 더 모으는 게 아닙니다. 클러스터 표준오차를 쓰거나 행이 아니라 클러스터를 관측 단위로 삼는 쪽입니다. 매장 12곳에서 뽑은 100만 행짜리 데이터에 담긴 정보량은 100만보다 12에 훨씬 가깝습니다.

The fix is not a bigger sample; it is clustered standard errors, or treating the cluster rather than the row as the unit of observation. A dataset of a million rows drawn from twelve stores carries closer to twelve units of information than a million.

꼬리가 두꺼울 때Heavy tails

원분포의 분산이 무한하면 나눌 σ가 없고 정리는 적용되지 않습니다. 생각보다 이국적인 상황이 아닙니다. 고객당 매출, 파일 크기, 도시 인구, 보험 청구액은 모두 그 경계 근처에 삽니다.

If the parent has infinite variance there is no σ to divide by, and the theorem simply does not apply. This is less exotic than it sounds: revenue per customer, file sizes, city populations and insurance claims all live near that boundary.

빠른 점검은 관측치를 늘려 가며 누적 평균을 그려 보는 것입니다. 수천 개를 넘겨도 계단처럼 뛰고 있다면 σ/√n을 믿지 마십시오.

A quick check is to plot the running mean as observations accumulate. If it is still visibly stepping after thousands of points, stop trusting σ/√n.

평균이 아닌 통계량일 때The wrong statistic

중심극한정리는 평균에 대한 것입니다. 중앙값, 최댓값, 비율, 분위수에 대해서는 아무 말도 하지 않습니다. 표본 최댓값은 전혀 다른 분포족으로 수렴합니다. 그게 극단값 이론입니다. 99분위 지연시간 지표에 평균 모양의 표준오차를 붙이는 것은 흔하고 조용한 실수입니다.

The theorem is about means. It says nothing about medians, maxima, ratios or quantiles. Sample maxima converge to an entirely different family of distributions, which is extreme value theory. Applying a mean-shaped standard error to a 99th-percentile latency metric is a common and quiet mistake.

실무에서In practice

  • 구간을 믿기 전에 왜도를 재십시오. 코드 한 줄이면 됩니다. 왜도/√n이 0.2를 넘으면 표본을 더 모으거나 부트스트랩으로 바꾸십시오.
  • 애매하면 부트스트랩. 재표본추출은 정규성을 가정하지 않고 요즘 하드웨어에서는 1초도 안 걸립니다. 비대칭 데이터라면 BCa 구간이 위에서 본 커버리지 격차를 대부분 메워 줍니다.
  • 오른쪽으로 치우친 양수 변수는 로그를 취하십시오. 매출, 소요시간, 횟수 같은 것들입니다. 느리게 수렴하던 문제가 빠르게 수렴하는 문제로 바뀝니다. 대신 추정 대상이 산술평균에서 기하평균으로 바뀌니 상대방이 원하는 게 어느 쪽인지 분명히 하십시오.
  • 행이 아니라 클러스터를 세십시오. 관측치가 사용자나 지점 안에서 반복된다면 유효 n은 클러스터 수입니다.
  • 평균이 5 미만인 카운트 데이터에는 정규근사를 밀어 넣지 말고 포아송이나 음이항 모형을 쓰십시오.
  • Estimate the skewness before trusting the interval. One line of code. If skew/√n exceeds about 0.2, either collect more data or switch to a bootstrap.
  • Bootstrap when unsure. Resampling assumes no normality and costs a fraction of a second. For skewed data, BCa intervals close most of the coverage gap seen above.
  • Log-transform right-skewed positive quantities such as revenue, duration and counts. It often converts a slow-converging problem into a fast one, at the cost of your estimand becoming the geometric rather than arithmetic mean. Be explicit about which one the stakeholder wants.
  • Count clusters, not rows. When observations repeat within users or sites, the effective n is the number of clusters.
  • Do not force a normal approximation onto low counts. For data averaging under five, reach for a Poisson or negative binomial model.

어디서 마주치게 되는가Where this shows up

  • 금융. 정규 수익률을 가정한 VaR 모형은 위험을 과소평가합니다. 수익률 분포의 꼬리가 두껍기 때문입니다. 2008년의 "25 표준편차 사건"은 운이 나빴던 게 아니라 가정이 무너진 것입니다.
  • 품질관리. 관리도는 찍히는 통계량이 정규분포라고 가정합니다. 이건 부분군 평균에서 성립합니다. 관리도가 개별 측정값이 아니라 평균을 찍는 이유가 정확히 그것입니다.
  • A/B 테스트. 전환율은 비율이고 비율은 0/1 변수의 평균이므로 정리가 적용됩니다. 다만 기저 전환율이 아주 낮으면 수렴이 느립니다.
  • 임상시험. 표본 수 계산은 중심극한정리 산수입니다. 생존시간처럼 비대칭인 종료점은 위에서 본 이유들 때문에 다른 도구로 다룹니다.
  • Finance. Value-at-risk models built on normal returns understate risk precisely because return distributions are heavy-tailed. The 2008 "25-standard-deviation events" were an assumption failing, not a run of bad luck.
  • Quality control. Control charts assume the plotted statistic is normal. That holds for subgroup means, which is exactly why control charts plot means rather than individual measurements.
  • A/B testing. Conversion rates are proportions, which are means of 0/1 variables, so the theorem applies — but slowly when the base rate is very low.
  • Clinical trials. Sample size calculations are CLT arithmetic. Skewed endpoints such as time-to-event are handled with different machinery for exactly the reasons above.

이 시리즈의 나머지는 이 정리에 계속 기댑니다. 인과추론 편의 모든 표준오차, 실험 설계 편의 모든 신뢰구간이 그렇습니다. 무엇을 약속하고 있고 언제 약속하지 않는지 알아 둘 값어치가 있습니다.

The rest of this series leans on the theorem constantly — every standard error in the causal inference posts, every confidence interval in the experiment design posts. It is worth knowing exactly what it promises you, and when it does not.