| |

The Chi-Squared Distribution

The Chi-Squared Distribution

Version 6 | Created: 2026-09-04 | Updated: 2026-11-07 13:46 UTC

ν‘œμ€€μ •κ·œ ν™•λ₯ λ³€μˆ˜μ˜ μ œκ³±ν•©μ΄ λ”°λ₯΄λŠ” 뢄포에 λŒ€ν•œ 기둝. μ–΄λ–»κ²Œ λ§Œλ“€μ–΄μ§€λŠ”μ§€, λ°€λ„ν•¨μˆ˜μ™€ moment κ°€ 무엇인지, λ‹€λ₯Έ ν‘œλ³ΈλΆ„ν¬μ™€ μ–΄λ–»κ²Œ μ΄μ–΄μ§€λŠ”μ§€, 그리고 이λ₯Ό μ“°λŠ” 검정에 μ™œ λ“±μž₯ν•˜λŠ”μ§€λ₯Ό 닀룬닀.

1. Scope

Chi-squared distribution 은 자료의 model 둜 λ§Œλ‚˜λŠ” 일이 λ“œλ¬Όλ‹€. ν†΅κ³„λŸ‰μ˜ λΆ„ν¬λ‘œ λ§Œλ‚˜λ©°, μ„±μ§ˆμ΄ μ•„μ£Ό λ‹€λ₯Έ 두 양이 κ³΅κ΅λ‘­κ²Œλ„ 이 뢄포λ₯Ό λ”°λ₯΄κΈ°μ— 자리λ₯Ό μ–»λŠ”λ‹€. ν•˜λ‚˜λŠ” μ •κ·œλͺ¨μ§‘λ‹¨μ˜ μ²™λ„μ‘°μ •λœ sample variance 이고, λ‹€λ₯Έ ν•˜λ‚˜λŠ” κ΄€μΈ‘λ„μˆ˜μ™€ κΈ°λŒ€λ„μˆ˜μ˜ 차이λ₯Ό μž¬λŠ” Pearson 의 츑도이닀. λ‘˜ λ‹€ κ·Όμ‚¬μ μœΌλ‘œ ν‘œμ€€μ •κ·œμΈ μ–‘λ“€μ˜ μ œκ³±ν•©μœΌλ‘œ ν™˜μ›λ˜λ©°, κ·Έ μ œκ³±ν•©μ΄ λ°”λ‘œ 이 뢄포가 κΈ°μˆ ν•˜λŠ” λŒ€μƒμ΄λ‹€.

이 λ¬Έμ„œλŠ” 뢄포λ₯Ό μ •μ˜ν•˜κ³ , λ°€λ„ν•¨μˆ˜μ™€ moment λ₯Ό μ œμ‹œν•˜κ³ , normalΒ·gammaΒ·tΒ·F distribution 과의 관계λ₯Ό μ •λ¦¬ν•˜κ³ , μœ„μ˜ 두 상황을 보인닀. μœ λ„λŠ” Appendix B 에, 뢄포λ₯Ό κ³„μ‚°ν•˜λŠ” ν˜ΈμΆœμ€ Appendix C 에 λ‘”λ‹€.

2. Definition

2.1. Construction from Normal Variables

$Z_1, \ldots, Z_k$ λ₯Ό 독립인 ν‘œμ€€μ •κ·œ ν™•λ₯ λ³€μˆ˜λΌ ν•˜μž. μžμœ λ„ (degrees of freedom) κ°€ $k$ 인 chi-squared distribution 은 μ΄λ“€μ˜ μ œκ³±ν•©μ΄ λ”°λ₯΄λŠ” 뢄포이며 $X \sim \chi^2_k$ 둜 μ λŠ”λ‹€.

$$X = \sum_{i=1}^{k} Z_i^{2} \hspace{19em} (1)$$

이 ꡬ성이 ν•œκΊΌλ²ˆμ— μ„Έ κ°€μ§€λ₯Ό μ •ν•œλ‹€. μ œκ³±ν•©μ€ μŒμˆ˜κ°€ 될 수 μ—†μœΌλ―€λ‘œ support λŠ” $x \ge 0$ 이닀. parameter λŠ” $k$ ν•˜λ‚˜λΏμ΄λ©°, 그것은 λ”ν•΄μ§€λŠ” 제곱의 개수λ₯Ό μ„Όλ‹€. 그리고 μ œκ³±μ€ μ •κ·œλΆ„ν¬μ˜ 두 꼬리λ₯Ό ν•œμͺ½μœΌλ‘œ μ ‘μœΌλ―€λ‘œ 이 λΆ„ν¬λŠ” λŒ€μΉ­μ΄ μ•„λ‹ˆλ‹€.

2.2. Density Function

$x \gt 0$ μ—μ„œ $\chi^2_k$ 의 λ°€λ„ν•¨μˆ˜μ—λŠ” gamma function $\Gamma$ κ°€ λ“€μ–΄κ°„λ‹€.

$$f(x) = \frac{1}{2^{k/2} \Gamma(k/2)} x^{k/2 - 1} e^{-x/2} \hspace{19em} (2)$$

이 μ‹μ˜ 어디에도 $k$ κ°€ μ •μˆ˜μ—¬μ•Ό ν•  μ΄μœ λŠ” μ—†λ‹€. section 2.1 의 μ„ΈλŠ” 방식은 μ •μˆ˜ $k$ λ₯Ό μ£Όμ§€λ§Œ, λ°€λ„ν•¨μˆ˜ μžμ²΄λŠ” λͺ¨λ“  μ‹€μˆ˜ $k \gt 0$ 에 λŒ€ν•΄ μ„±λ¦½ν•œλ‹€. μ–΄λ–€ 근사가 λ§Œλ“€μ–΄λ‚΄λŠ” μ†Œμˆ˜ μžμœ λ„λ₯Ό 이 λΆ„ν¬λ‘œ 받을 수 μžˆλŠ” 것은 κ·Έ λ•Œλ¬Έμ΄λ‹€ [4].

Moment generating function 은 λ°€λ„ν•¨μˆ˜λ³΄λ‹€ λ‹¨μˆœν•˜λ©°, 뒀에 μ˜€λŠ” λŒ€λΆ€λΆ„μ˜ λ…Όμ˜κ°€ 이것을 λ„κ΅¬λ‘œ μ“΄λ‹€.

$$M(t) = E\left[ e^{tX} \right] = (1 - 2t)^{-k/2}, \qquad t \lt \tfrac{1}{2} \hspace{19em} (3)$$

3. Properties

3.1. Moments

식 (3) 을 μ›μ μ—μ„œ λ―ΈλΆ„ν•˜λ©΄ moment κ°€ λ‚˜μ˜¨λ‹€. 평균은 μžμœ λ„μ™€ κ°™κ³  뢄산은 κ·Έ 두 배이닀.

$$E[X] = k, \qquad \mathrm{Var}[X] = 2k, \qquad \gamma_1 = \sqrt{8/k}, \qquad \gamma_2 = 12/k \hspace{19em} (4)$$

μ—¬κΈ°μ„œ $\gamma_1$ 은 μ™œλ„ (skewness), $\gamma_2$ λŠ” μ΄ˆκ³Όμ²¨λ„ (excess kurtosis) 이닀. λ‘˜ λ‹€ $k$ κ°€ 컀지면 쀄어듀며, 이 λΆ„ν¬μ˜ λŒ€ν‘œλ³Έ 거동은 이 두 μˆ˜κ°€ 전뢀이닀.

Table 1. Moments of the chi-squared distribution.

Degrees of freedom Mean Variance Skewness Excess kurtosis
1 1 2 2.8284 12.0
2 2 4 2.0000 6.0
3 3 6 1.6330 4.0
5 5 10 1.2649 2.4
10 10 20 0.8944 1.2

평균이 $k$ 와 κ°™λ‹€λŠ” 것은 κΈ°μ–΅ν•΄ λ‘˜ λ§Œν•˜λ‹€. $\chi^2_k$ λ₯Ό 따라야 ν•  κ²€μ •ν†΅κ³„λŸ‰μ΄ $k$ κ·Όμ²˜μ—μ„œ λ‚˜μ˜€λ©΄ νŠΉλ³„ν•  것이 μ—†κ³ , $k$ 의 λͺ‡ 배둜 λ‚˜μ˜€λ©΄ 그것이 검정이 μ°ΎλŠ” μ‹ ν˜Έμ΄λ‹€.

3.2. Additivity

$X \sim \chi^2_m$ κ³Ό $Y \sim \chi^2_n$ 이 독립이면 κ·Έ 합도 chi-squared 이며 μžμœ λ„λŠ” 더해진닀.

$$X + Y \sim \chi^2_{m+n} \hspace{19em} (5)$$

독립인 두 μ œκ³±ν•©μ˜ 합은 λ‹€μ‹œ μ œκ³±ν•©μ΄λ―€λ‘œ 식 (1) μ—μ„œ κ³§λ°”λ‘œ λ”°λ₯΄κ³ , 두 moment generating function 의 곱이 μ§€μˆ˜ $-(m+n)/2$ 인 것과 κ°™μœΌλ―€λ‘œ 식 (3) μ—μ„œλ„ λ˜‘κ°™μ΄ λ”°λ₯Έλ‹€. μžμœ λ„κ°€ 개수처럼 μ›€μ§μ΄λŠ” 것은 그것이 개수이기 λ•Œλ¬Έμ΄λ‹€.

3.3. Shape

λͺ¨μ–‘은 $k$ 에 따라 질적으둜 달라진닀. $k = 1$ μ—μ„œ λ°€λ„ν•¨μˆ˜λŠ” μ›μ μ—μ„œ λ°œμ‚°ν•˜κ³ , $k = 2$ μ—μ„œλŠ” exponential λ°€λ„ν•¨μˆ˜μ—¬μ„œ μ›μ μ—μ„œ μœ ν•œν•˜μ§€λ§Œ μ—¬μ „νžˆ κ°μ†Œν•œλ‹€. $k = 3$ λΆ€ν„°λŠ” μ›μ μ—μ„œ 0 이 되고 단봉이며, mode λŠ” $k - 2$ 에 μžˆλ‹€.

Fig 1

Fig 1. Chi-squared density (a) and distribution function (b) for five values of the degrees of freedom. The density for $k = 1$ leaves the top of the panel; it is unbounded at the origin.

$k$ κ°€ 컀지면 λ°€λ„ν•¨μˆ˜λŠ” 점점 λŒ€μΉ­μ— κ°€κΉŒμ›Œμ§€κ³ , ν‘œμ€€ν™”ν•œ λ³€μˆ˜λŠ” ν‘œμ€€μ •κ·œλΆ„ν¬λ‘œ μˆ˜λ ΄ν•œλ‹€.

$$\frac{X - k}{\sqrt{2k}} \xrightarrow{d} N(0, 1) \hspace{19em} (6)$$

μˆ˜λ ΄μ€ λŠλ¦¬λ‹€. 식 (4) 의 μ™œλ„κ°€ $k^{-1/2}$ 둜만 쀄기 λ•Œλ¬Έμ΄λ©°, κ·Έ 느림이 μ •κ·œ 근사 λŒ€μ‹  이 λΆ„ν¬μ˜ ν‘œκ°€ 였래 쓰인 μ΄μœ μ΄λ‹€. $k = 10$ μ—μ„œ μƒμœ„ 5 percent 점은 18.307 인데 식 (6) 은 17.356 을 μ£Όμ–΄ 5 percent 의 μ˜€μ°¨κ°€ λ‚œλ‹€. 같은 $k$ μ—μ„œ Wilson κ³Ό Hilferty 의 μ„Έμ œκ³±κ·Ό λ³€ν™˜ [1] 은 18.292 λ₯Ό μ£Όμ–΄ 훨씬 λ‚«λ‹€.

Table 2. Upper-tail critical values: the value the statistic exceeds with the stated probability.

Degrees of freedom 0.10 0.05 0.01
1 2.706 3.841 6.635
2 4.605 5.991 9.210
3 6.251 7.815 11.345
4 7.779 9.488 13.277
5 9.236 11.070 15.086
6 10.645 12.592 16.812
7 12.017 14.067 18.475
8 13.362 15.507 20.090
9 14.684 16.919 21.666
10 15.987 18.307 23.209
15 22.307 24.996 30.578
20 28.412 31.410 37.566
30 40.256 43.773 50.892

4. Relation to Other Distributions

Chi-squared distribution 은 μ •κ·œμ΄λ‘  ν‘œλ³ΈλΆ„ν¬λ“€μ˜ ν•œκ°€μš΄λ°μ— 있고, λ‚˜λ¨Έμ§€ λŒ€λΆ€λΆ„μ€ μ΄κ²ƒμœΌλ‘œλΆ€ν„° λ§Œλ“€μ–΄μ§„λ‹€.

Table 3. Relations to other distributions.

Distribution Relation Note
Normal $Z^2 \sim \chi^2_1$ $k = 1$ 인 경우
Exponential $\chi^2_2$ λŠ” 평균이 2 인 exponential $k = 2$ 인 경우
Gamma $\chi^2_k$ λŠ” shape $k/2$, scale 2 인 gamma λ°€λ„ν•¨μˆ˜μ˜ μΌλ°˜ν˜•
Student t $Z / \sqrt{V/k}$, $V \sim \chi^2_k$ 이며 $Z$ 와 독립 Chi-squared κ°€ λΆ„λͺ¨
F $(V_1/k_1) / (V_2/k_2)$, $V_1, V_2$ λŠ” 독립 두 chi-squared 의 λΉ„
Noncentral chi-squared 평균이 0 이 μ•„λ‹Œ μ •κ·œ λ³€μˆ˜λ“€μ˜ μ œκ³±ν•© μ•„λž˜ κ²€μ •λ“€μ˜ κ²€μ •λ ₯에 μ“°μž„

첫 행은 Table 2 둜 확인할 수 μžˆλ‹€. ν‘œμ€€μ •κ·œμ˜ μ–‘μΈ‘ 5 percent 점은 1.96 이고 $1.96^2 = 3.8415$ 인데, 이것이 $\chi^2_1$ 의 5 percent 점이닀. μ •κ·œ 평균에 λŒ€ν•œ μ–‘μΈ‘κ²€μ •κ³Ό κ·Έ μ œκ³±μ— λŒ€ν•œ 단츑검정은 같은 검정이닀.

5. Role in Sampling

5.1. Sample Variance of a Normal Population

$x_1, \ldots, x_n$ 을 $N(\mu, \sigma^2)$ μ—μ„œ λ…λ¦½μœΌλ‘œ 뽑고 sample mean 을 $\bar{x}$, sample variance λ₯Ό $s^2$ 라 ν•˜λ©΄, μ²™λ„μ‘°μ •λœ sample variance λŠ” ν‘œλ³Έ 크기보닀 μžμœ λ„κ°€ ν•˜λ‚˜ 적은 chi-squared λ₯Ό λ”°λ₯΄λ©° $\bar{x}$ 와 독립이닀.

$$\frac{(n-1)s^{2}}{\sigma^{2}} \sim \chi^2_{n-1} \hspace{19em} (7)$$

μžƒλŠ” μžμœ λ„ ν•˜λ‚˜λŠ” $\mu$ λ₯Ό μΆ”μ •ν•˜λŠ” 데 μ“΄ 것이닀. 편차 $x_i - \bar{x}$ λŠ” ꡬ성상 합이 0 μ΄λ―€λ‘œ 그쀑 $n-1$ 개만 자유둭게 κ³ λ₯Ό 수 있고, κ·Έ μ œκ³±ν•©μ€ $n$ κ°œκ°€ μ•„λ‹ˆλΌ $n-1$ 개의 독립인 제곱의 ν•©μ²˜λŸΌ 움직인닀. κ²°κ³Όκ°€ μ •ν™•νžˆ chi-squared 이고 평균과 μ •ν™•νžˆ λ…λ¦½μ΄λΌλŠ” 것이 Cochran 의 정리이닀 [2].

식 (7) 을 λ’€μ§‘μœΌλ©΄ μ •κ·œ λΆ„μ‚°μ˜ confidence interval 이 λ‚˜μ˜€λ©°, 뢄포가 λΉ„λŒ€μΉ­μ΄λ―€λ‘œ ꡬ간도 λΉ„λŒ€μΉ­μ΄λ‹€.

$$\left[ \frac{(n-1)s^{2}}{\chi^2_{n-1, \alpha/2}}, \ \frac{(n-1)s^{2}}{\chi^2_{n-1, 1-\alpha/2}} \right] \hspace{19em} (8)$$

5.2. Degrees of Freedom

이 뢄포λ₯Ό μ“°λŠ” λͺ¨λ“  μžλ¦¬μ—μ„œ μžμœ λ„λŠ” μ œμ•½μ΄ κ±Έλ¦° 뒀에도 자유둭게 λ³€ν•  수 μžˆλŠ” μ–‘μ˜ 개수λ₯Ό μ„Έλ©°, 같은 μžλ£Œμ—μ„œ μΆ”μ •ν•œ parameter ν•˜λ‚˜λ§ˆλ‹€ ν•˜λ‚˜μ”© 쀄어든닀. 식 (7) μ—μ„œ μ œμ•½μ€ μΆ”μ •ν•œ 평균 ν•˜λ‚˜μ΄κ³ , section 6 의 κ²€μ •μ—μ„œλŠ” κΈ°λŒ€λ„μˆ˜κ°€ λ§žμΆ°μ•Ό ν•˜λŠ” ν•©κ³„μ—μ„œ μ œμ•½μ΄ λ‚˜μ˜¨λ‹€. 이 개수λ₯Ό 틀리면 ν†΅κ³„λŸ‰μ΄ ν‹€λ¦¬λŠ” 것이 μ•„λ‹ˆλΌ 기쀀뢄포가 ν‹€λ¦¬λŠ”λ°, κ·Έμͺ½μ΄ μ•Œμ•„μ±„κΈ° 더 μ–΄λ ΅λ‹€.

6. Tests Built on the Distribution

6.1. Goodness of Fit

$m$ 개의 cell 에 λ–¨μ–΄μ§„ λ„μˆ˜ $O_1, \ldots, O_m$ κ³Ό 가섀이 κΈ°λŒ€ν•˜λŠ” λ„μˆ˜ $E_1, \ldots, E_m$ 이 μ£Όμ–΄μ§€λ©΄, Pearson 의 ν†΅κ³„λŸ‰μ΄ κ·Έ 차이λ₯Ό μž°λ‹€ [3].

$$X^{2} = \sum_{j=1}^{m} \frac{(O_j - E_j)^{2}}{E_j} \hspace{19em} (9)$$

κ°€μ„€ μ•„λž˜μ—μ„œ 각 항은 λŒ€λž΅ ν‘œμ€€ν™”λœ 편차의 μ œκ³±μ΄λ―€λ‘œ 합은 λŒ€λž΅ ν‘œμ€€μ •κ·œμ˜ μ œκ³±ν•©μ΄ 되고 식 (1) 이 μ μš©λœλ‹€. μžλ£Œμ—μ„œ μΆ”μ •ν•œ parameter κ°€ μ—†μœΌλ©΄ μžμœ λ„λŠ” $m - 1$ 이며, μœ μΌν•œ μ œμ•½μ€ κΈ°λŒ€λ„μˆ˜μ˜ 합이 κ΄€μΈ‘λ„μˆ˜μ˜ ν•©κ³Ό κ°™μ•„μ•Ό ν•œλ‹€λŠ” 것이닀.

μ£Όμ‚¬μœ„λ₯Ό 300 번 κ΅΄λ € 43, 52, 54, 61, 48, 42 κ°€ λ‚˜μ™”λ‹€λ©΄ κΈ°λŒ€λ„μˆ˜λŠ” λͺ¨λ‘ 50 이고 ν†΅κ³„λŸ‰μ€ μžμœ λ„ 5 μ—μ„œ 5.160 이닀. Table 2 κ°€ 5 percent 점으둜 11.070 을 μ£Όλ―€λ‘œ 이 λ„μˆ˜λŠ” νŠΉλ³„ν•  것이 μ—†μœΌλ©°, μ •ν™•ν•œ μƒμœ„κΌ¬λ¦¬ ν™•λ₯ μ€ 0.397 이닀.

이 검정을 λ°›μΉ˜λŠ” 것은 각 cell λ„μˆ˜μ— λŒ€ν•œ μ •κ·œ 근사이고, κΈ°λŒ€λ„μˆ˜κ°€ μž‘μœΌλ©΄ κ·Έ 근사가 κΉ¨μ§„λ‹€. ν†΅μƒμ˜ 싀무 기쀀은 λͺ¨λ“  κΈ°λŒ€λ„μˆ˜κ°€ 5 이상이어야 ν•œλ‹€λŠ” 것이닀.

6.2. Independence in a Contingency Table

행이 $r$ 개, 열이 $c$ 개인 λ„μˆ˜ν‘œμ—μ„œ ν–‰ λΆ„λ₯˜μ™€ μ—΄ λΆ„λ₯˜κ°€ λ…λ¦½μ΄λΌλŠ” 가섀은 각 cell 을 margin 만으둜 μ˜ˆμΈ‘ν•˜λ©°, κ·Έ μ˜ˆμΈ‘κ°’μ— 식 (9) λ₯Ό μ μš©ν•œλ‹€.

$$E_{ij} = \frac{R_i C_j}{n} \hspace{19em} (10)$$

μžμœ λ„λŠ” section 5.2 λ₯Ό λ”°λ₯Έλ‹€. ν‘œμ—λŠ” $rc$ 개의 cell 이 있고 margin μ—μ„œ μΆ”μ •ν•œ ν–‰Β·μ—΄ λΉ„μœ¨μ΄ 그쀑 $(r-1) + (c-1)$ 개λ₯Ό μ—†μ• λ―€λ‘œ $rc - 1 - (r-1) - (c-1) = (r-1)(c-1)$ 이 λ‚¨λŠ”λ‹€.

행이 38, 62 와 51, 49 인 2Γ—2 ν‘œμ—μ„œλŠ” κΈ°λŒ€λ„μˆ˜κ°€ λͺ¨λ‘ 44.5 μ•„λ‹ˆλ©΄ 55.5 이고, ν†΅κ³„λŸ‰μ€ μžμœ λ„ 1 μ—μ„œ 3.421, μƒμœ„κΌ¬λ¦¬ ν™•λ₯ μ€ 0.064 이닀. Table 2 의 3.841 에 견주면 두 ν–‰μ˜ μ°¨μ΄λŠ” 5 percent μˆ˜μ€€μ—μ„œ μœ μ˜ν•˜μ§€ μ•Šλ‹€.

References

[1] Wilson, E. B., & Hilferty, M. M. (1931). The Distribution of Chi-Square. Proceedings of the National Academy of Sciences, 17(12), 684–688.
[2] Cochran, W. G. (1934). The Distribution of Quadratic Forms in a Normal System, with Applications to the Analysis of Covariance. Mathematical Proceedings of the Cambridge Philosophical Society, 30(2), 178–191.
[3] Pearson, K. (1900). On the Criterion that a Given System of Deviations from the Probable in the Case of a Correlated System of Variables is Such that it Can be Reasonably Supposed to have Arisen from Random Sampling. The London, Edinburgh, and Dublin Philosophical Magazine and Journal of Science, 50(302), 157–175.
[4] Johnson, N. L., Kotz, S., & Balakrishnan, N. (1994). Continuous Univariate Distributions (Vol. 1, 2nd ed.). Wiley. ISBN 978-0-471-58495-7.


Appendix A. Terminology

  • Cell: λ„μˆ˜λ₯Ό λ‹΄λŠ”, λ²”μ£Ό λΆ„λ₯˜μ˜ ν•œ 갈래.
  • Contingency table: 두 λ²”μ£Όν˜• λ³€μˆ˜λ‘œ ꡐ차뢄λ₯˜ν•œ λ„μˆ˜ν‘œ.
  • Degrees of freedom: μ œμ•½μ΄ κ±Έλ¦° 뒀에도 자유둭게 λ³€ν•  수 μžˆλŠ” μ–‘μ˜ 개수이며, chi-squared distribution 의 parameter.
  • Excess kurtosis: λ„€ 번째 ν‘œμ€€ν™” moment μ—μ„œ 3 을 λΊ€ 값이며, μ •κ·œλΆ„ν¬μ—μ„œ 0.
  • Margin: λ„μˆ˜ν‘œμ˜ ν–‰ 합계 λ˜λŠ” μ—΄ 합계.
  • Moment generating function: $t$ 의 ν•¨μˆ˜λ‘œ λ³Έ $E[e^{tX}]$ 이며, μ›μ μ—μ„œμ˜ λ„ν•¨μˆ˜κ°€ moment.
  • Skewness: μ„Έ 번째 ν‘œμ€€ν™” moment 이며, λŒ€μΉ­λΆ„ν¬μ—μ„œ 0.
  • Support: 뢄포가 μ–‘μ˜ ν™•λ₯ μ„ μ£ΌλŠ” κ°’μ˜ μ§‘ν•©.
  • Survival function: 1 μ—μ„œ λΆ„ν¬ν•¨μˆ˜λ₯Ό λΊ€ 것, κ³§ μƒμœ„κΌ¬λ¦¬ ν™•λ₯ .

Appendix B. Derivations

B.1. Square of a Normal Variable

식 (1) 의 ꡬ성은 ν‘œμ€€μ •κ·œ λ³€μˆ˜μ—μ„œ μΆœλ°œν•˜μ§€λ§Œ, 츑정값이 ν‘œμ€€ν™”λœ μ±„λ‘œ μ˜€λŠ” 일은 λ“œλ¬Όλ‹€. μ•„λž˜ μ •λ¦¬λŠ” 일반적인 경우λ₯Ό 닀룬닀.

정리. $X$ κ°€ 연속확λ₯ λ³€μˆ˜μ΄κ³  $X \sim N(\mu, \sigma^{2})$, $\sigma \gt 0$ 이라 ν•˜μž. 그러면 ν‘œμ€€ν™”ν•œ 편차의 μ œκ³±μ€ μžμœ λ„κ°€ 1 인 chi-squared distribution 을 λ”°λ₯Έλ‹€.

$$Y = \frac{(X - \mu)^{2}}{\sigma^{2}} \sim \chi^2_1 \hspace{19em} (11)$$

증λͺ…. $Z = (X - \mu)/\sigma$ 둜 λ‘μž. μ •κ·œ λ³€μˆ˜μ˜ μΌμ°¨λ³€ν™˜μ€ μ •κ·œμ΄κ³  이 λ³€ν™˜μ€ 평균 0, λΆ„μ‚° 1 을 κ°€μ§€λ―€λ‘œ $Z \sim N(0, 1)$ 이고 $Y = Z^{2}$ 이닀.

$Y$ λŠ” μ œκ³±μ΄λ―€λ‘œ μŒμˆ˜κ°€ 될 수 μ—†κ³ , λ”°λΌμ„œ $y \le 0$ μ—μ„œ $F_Y(y) = 0$ 이닀. $y \gt 0$ μ—μ„œ 사건 $Y \le y$ λŠ” 사건 $-\sqrt{y} \le Z \le \sqrt{y}$ 와 κ°™μœΌλ―€λ‘œ, $Y$ 의 λΆ„ν¬ν•¨μˆ˜λŠ” $\Phi$ 둜 μ λŠ” $Z$ 의 λΆ„ν¬ν•¨μˆ˜μ—μ„œ 따라 λ‚˜μ˜¨λ‹€. 두 번째 λ“±ν˜ΈλŠ” ν‘œμ€€μ •κ·œμ˜ λŒ€μΉ­μ„±μ„ μ“΄λ‹€.

$$F_Y(y) = \Phi(\sqrt{y}) - \Phi(-\sqrt{y}) = 2\Phi(\sqrt{y}) - 1 \hspace{19em} (12)$$

$y$ 둜 λ―ΈλΆ„ν•œλ‹€. 연쇄법칙이 $\sqrt{y}$ 의 λ„ν•¨μˆ˜μΈ $1/(2\sqrt{y})$ λ₯Ό 내놓고, $\Phi' = \phi$ λŠ” ν‘œμ€€μ •κ·œ λ°€λ„ν•¨μˆ˜ $\phi(z) = e^{-z^{2}/2}/\sqrt{2\pi}$ 이닀.

$$f_Y(y) = 2 \phi(\sqrt{y}) \cdot \frac{1}{2\sqrt{y}} = \frac{1}{\sqrt{2\pi}} y^{-1/2} e^{-y/2} \hspace{19em} (13)$$

남은 일은 식 (13) 을 μ•Œμ•„λ³΄λŠ” 것이닀. 식 (2) 에 $k = 1$ 을 λ„£μœΌλ©΄ λ°€λ„ν•¨μˆ˜ $y^{-1/2} e^{-y/2} / \left( 2^{1/2}\Gamma(1/2) \right)$ κ°€ λ˜λŠ”λ°, $\Gamma(1/2) = \sqrt{\pi}$ μ΄λ―€λ‘œ κ·Έ μƒμˆ˜λŠ” $\sqrt{2}\sqrt{\pi} = \sqrt{2\pi}$ 이닀. 두 λ°€λ„ν•¨μˆ˜λŠ” $y \gt 0$ μ—μ„œ μΌμΉ˜ν•˜κ³  κ·Έ λ°–μ—μ„œλŠ” λ‘˜ λ‹€ 0 μ΄λ―€λ‘œ $Y \sim \chi^2_1$ 이닀. $\blacksquare$

식 (5) 와 ν•¨κ»˜ 읽으면, 이 μ •λ¦¬λŠ” ν‘œμ€€μ •κ·œ λ³€μˆ˜κ°€ μ•„λ‹ˆλΌ μΈ‘μ •κ°’μ—μ„œ 이 뢄포쑱에 λ‹Ώκ²Œ ν•΄ μ£ΌλŠ” 것이닀. 독립인 μ •κ·œ κ΄€μΈ‘κ°’ $n$ 개λ₯Ό ν‘œμ€€ν™”ν•΄ μ œκ³±ν•˜λ©΄ 독립인 $\chi^2_1$ λ³€μˆ˜ $n$ κ°œκ°€ 되고, κ·Έ 합이 $\chi^2_n$ 이닀.

B.2. Moment Generating Function

제곱 ν•˜λ‚˜μ— λŒ€ν•΄, μ •μ˜ν•˜λŠ” μ λΆ„μ—μ„œ $u = z\sqrt{1-2t}$ 둜 μΉ˜ν™˜ν•œλ‹€. 이 μΉ˜ν™˜μ€ $t \lt 1/2$ μ—μ„œλ§Œ μ •λ‹Ήν•˜λ©°, κ·Έ λ²”μœ„μ—μ„œ μ§€μˆ˜κ°€ 음수둜 남아 적뢄이 μˆ˜λ ΄ν•œλ‹€.

$$E\left[ e^{tZ^{2}} \right] = \int_{-\infty}^{\infty} \frac{1}{\sqrt{2\pi}} e^{tz^{2}} e^{-z^{2}/2} dz = \frac{1}{\sqrt{1-2t}} \int_{-\infty}^{\infty} \frac{e^{-u^{2}/2}}{\sqrt{2\pi}} du = (1-2t)^{-1/2} \hspace{19em} (14)$$

남은 적뢄은 ν‘œμ€€μ •κ·œ λ°€λ„ν•¨μˆ˜μ˜ 전체 μ§ˆλŸ‰μ΄λ―€λ‘œ 1 이닀. 식 (1) 의 $Z_i$ κ°€ λ…λ¦½μ΄λ―€λ‘œ κ·Έ ν•©μ˜ moment generating function 은 이런 인자 $k$ 개의 곱이고, 그것이 식 (3) 이닀. 식 (5) λŠ” 같은 말을 거꾸둜 읽은 κ²ƒμœΌλ‘œ, $(1-2t)^{-m/2}$ 와 $(1-2t)^{-n/2}$ 의 곱이 $(1-2t)^{-(m+n)/2}$ 이닀.

B.3. Mean and Variance

식 (3) 을 μ›μ μ—μ„œ μ „κ°œν•˜κ±°λ‚˜ 두 번 λ―ΈλΆ„ν•œλ‹€. $t = 0$ μ—μ„œμ˜ 처음 두 λ„ν•¨μˆ˜κ°€ 처음 두 raw moment λ₯Ό μ€€λ‹€.

$$M'(t) = k(1-2t)^{-k/2 - 1}, \qquad M''(t) = k(k+2)(1-2t)^{-k/2 - 2} \hspace{19em} (15)$$

$t = 0$ 을 λ„£μœΌλ©΄ $E[X] = k$ 와 $E[X^2] = k(k+2)$ κ°€ λ‚˜μ˜€λ―€λ‘œ 뢄산은 $k(k+2) - k^2 = 2k$ 이고, 이것이 식 (4) 이닀.

B.4. Loss of One Degree of Freedom

μ°Έν‰κ· μ—μ„œμ˜ νŽΈμ°¨μ œκ³±ν•©μ„ μ“°κ³  각 제곱 μ•ˆμ—μ„œ $\bar{x}$ λ₯Ό λ”ν–ˆλ‹€ λΊ€λ‹€. μ „κ°œν•˜λ©΄ μ„Έ 쑰각이 λ‚˜μ˜¨λ‹€. $\bar{x}$ μ—μ„œμ˜ νŽΈμ°¨μ œκ³±ν•©, ꡐ차항, 그리고 $n(\bar{x} - \mu)^2$ 이닀.

$$\sum_{i=1}^{n} (x_i - \mu)^{2} = \sum_{i=1}^{n} (x_i - \bar{x})^{2} + 2(\bar{x} - \mu)\sum_{i=1}^{n}(x_i - \bar{x}) + n(\bar{x} - \mu)^{2} \hspace{19em} (16)$$

$\bar{x}$ μ—μ„œμ˜ νŽΈμ°¨λŠ” 합이 0 μ΄λ―€λ‘œ ꡐ차항이 사라지고 두 쑰각이 λ‚¨λŠ”λ‹€. $\sigma^2$ 으둜 λ‚˜λˆ„λ©΄ μ’Œλ³€μ€ ν‘œμ€€μ •κ·œ 제곱 $n$ 개의 ν•©μ΄λ―€λ‘œ $\chi^2_n$ 이닀. λ§ˆμ§€λ§‰ 항은 $\left( (\bar{x}-\mu)/(\sigma/\sqrt{n}) \right)^2$, κ³§ ν‘œμ€€μ •κ·œ 제곱 ν•˜λ‚˜μ΄λ―€λ‘œ $\chi^2_1$ 이닀. Cochran 의 정리 [2] λŠ” μš°λ³€μ˜ 두 항이 독립이고 각각 chi-squared 라고 λ§ν•˜λ―€λ‘œ, μžμœ λ„κ°€ λΉΌμ Έ 첫 항은 $\chi^2_{n-1}$ 이닀. κ·Έ 첫 항이 $(n-1)s^2/\sigma^2$ 이며, 이것이 식 (7) 이닀.

Appendix C. Computation

뢄포와 κ·Έ μ—­ν•¨μˆ˜λŠ” scipy.stats.chi2 μ—μ„œ μ–»λŠ”λ‹€. Survival function sf λŠ” μƒμœ„κΌ¬λ¦¬λ₯Ό κ³§λ°”λ‘œ μ£Όλ©° 꼬리 κΉŠμ€ κ³³μ—μ„œ 정밀도λ₯Ό μžƒλŠ” 1 - cdf 보닀 λ‚«λ‹€. isf λŠ” 그것을 λ’€μ§‘μ–΄ Table 2 의 값을 λ§Œλ“ λ‹€.

# Python
from scipy import stats

print(stats.chi2.isf(0.05, df=5))       # upper 5 percent point
print(stats.chi2.sf(5.16, df=5))        # upper tail probability of an observed statistic
print(stats.chi2.stats(df=5, moments='mv'))
11.070497693516355
0.3966674666097388
(np.float64(5.0), np.float64(10.0))

Section 6 의 두 검정은 각각 호좜 ν•œ 번이고, λ‘˜ λ‹€ ν†΅κ³„λŸ‰κ³Ό κ·Έ μƒμœ„κΌ¬λ¦¬ ν™•λ₯ μ„ ν•¨κ»˜ λŒλ €μ€€λ‹€.

# Python
import numpy as np
from scipy import stats

print(stats.chisquare(f_obs=np.array([43, 52, 54, 61, 48, 42])))
statistic, p_value, degrees, expected = stats.chi2_contingency(np.array([[38, 62], [51, 49]]),
                                                               correction=False)
print(round(statistic, 4), degrees, round(p_value, 4))
Power_divergenceResult(statistic=np.float64(5.16), pvalue=np.float64(0.3966674666097388))
3.4214 1 0.0644

κΈ°λ³Έκ°’ 두 κ°€μ§€λŠ” μ•Œμ•„ λ‘˜ λ§Œν•˜λ‹€. stats.chisquare λŠ” f_exp λ₯Ό μ£Όμ§€ μ•ŠμœΌλ©΄ κΈ°λŒ€λ„μˆ˜κ°€ λͺ¨λ‘ κ°™λ‹€κ³  보며, ddof 둜 μΆ”μ •ν•œ parameter 개수λ₯Ό μ•Œλ €μ£Όμ§€ μ•ŠμœΌλ©΄ μžμœ λ„λ₯Ό $m - 1$ 둜 μž‘λŠ”λ‹€. stats.chi2_contingency λŠ” 2Γ—2 ν‘œμ—μ„œ Yates 의 연속성 보정을 기본으둜 μ μš©ν•˜λ―€λ‘œ, section 6.2 의 λ³΄μ •ν•˜μ§€ μ•Šμ€ ν†΅κ³„λŸ‰μ„ μž¬ν˜„ν•˜λ €λ©΄ correction=False κ°€ ν•„μš”ν•˜λ‹€.

The Chi-Squared Distribution

Version 9 | Created: 2026-09-03 | Updated: 2026-11-07 13:46 UTC

A note on the distribution of a sum of squared standard normal variables: how it is built, what its density and moments are, how it relates to the other sampling distributions, and why it turns up in the tests that use it.

1. Scope

The chi-squared distribution is not usually met as a model of data. It is met as the distribution of a statistic, and it earns its place because two very different quantities happen to follow it. One is the scaled sample variance of a normal population. The other is Pearson's measure of the gap between observed and expected counts. Both reduce to a sum of squares of quantities that are approximately standard normal, and that sum is what the distribution describes.

This document defines the distribution, gives its density and moments, sets out its relations to the normal, gamma, t and F distributions, and shows the two settings above. The derivations are in Appendix B and the calls that evaluate the distribution are in Appendix C.

2. Definition

2.1. Construction from Normal Variables

Let $Z_1, \ldots, Z_k$ be independent standard normal variables. The chi-squared distribution with $k$ degrees of freedom is the distribution of their sum of squares, written $X \sim \chi^2_k$.

$$X = \sum_{i=1}^{k} Z_i^{2} \hspace{19em} (1)$$

The construction fixes three things at once. The support is $x \ge 0$, because a sum of squares cannot be negative. The distribution has one parameter, $k$, and it counts the squares being added. The distribution is not symmetric, because squaring folds the two tails of the normal onto one side.

2.2. Density Function

The density of $\chi^2_k$ on $x \gt 0$ involves the gamma function $\Gamma$.

$$f(x) = \frac{1}{2^{k/2} \Gamma(k/2)} x^{k/2 - 1} e^{-x/2} \hspace{19em} (2)$$

Nothing in this expression requires $k$ to be a whole number. The counting construction of section 2.1 gives integer $k$, but the density is a proper density for every real $k \gt 0$, and that is what lets the distribution be used with the fractional degrees of freedom that some approximations produce [4].

The moment generating function is simpler than the density and is the tool used for most of what follows.

$$M(t) = E\left[ e^{tX} \right] = (1 - 2t)^{-k/2}, \qquad t \lt \tfrac{1}{2} \hspace{19em} (3)$$

3. Properties

3.1. Moments

Differentiating equation (3) at the origin gives the moments. The mean is the degrees of freedom and the variance is twice it.

$$E[X] = k, \qquad \mathrm{Var}[X] = 2k, \qquad \gamma_1 = \sqrt{8/k}, \qquad \gamma_2 = 12/k \hspace{19em} (4)$$

Here $\gamma_1$ is the skewness and $\gamma_2$ the excess kurtosis. Both fall as $k$ grows, which is the whole of the distribution's large-sample behaviour in two numbers.

Table 1. Moments of the chi-squared distribution.

Degrees of freedom Mean Variance Skewness Excess kurtosis
1 1 2 2.8284 12.0
2 2 4 2.0000 6.0
3 3 6 1.6330 4.0
5 5 10 1.2649 2.4
10 10 20 0.8944 1.2

That the mean equals $k$ is worth holding on to. A test statistic that is supposed to be $\chi^2_k$ and comes out near $k$ is unremarkable; one that comes out at several times $k$ is the signal the test is looking for.

3.2. Additivity

If $X \sim \chi^2_m$ and $Y \sim \chi^2_n$ are independent, their sum is chi-squared and the degrees of freedom add.

$$X + Y \sim \chi^2_{m+n} \hspace{19em} (5)$$

This follows immediately from equation (1), since the sum of two independent sums of squares is again a sum of squares, and just as directly from equation (3), since the product of the two moment generating functions is the one with exponent $-(m+n)/2$. Degrees of freedom behave like a count because they are one.

3.3. Shape

The shape changes qualitatively with $k$. For $k = 1$ the density diverges at the origin, and for $k = 2$ it is the exponential density, which is finite at the origin but still decreasing. From $k = 3$ the density vanishes at the origin and is unimodal, with the mode at $k - 2$.

Fig 1

Fig 1. Chi-squared density (a) and distribution function (b) for five values of the degrees of freedom. The density for $k = 1$ leaves the top of the panel; it is unbounded at the origin.

As $k$ grows the density becomes more symmetric, and the standardised variable converges to the standard normal.

$$\frac{X - k}{\sqrt{2k}} \xrightarrow{d} N(0, 1) \hspace{19em} (6)$$

The convergence is slow, because the skewness in equation (4) falls only as $k^{-1/2}$, and that slowness is why tables of the distribution stayed in use rather than a normal approximation. At $k = 10$ the upper 5 percent point is 18.307, while equation (6) gives 17.356, an error of 5 percent. The cube-root transform of Wilson and Hilferty [1] is far better at the same $k$, giving 18.292.

Table 2. Upper-tail critical values: the value the statistic exceeds with the stated probability.

Degrees of freedom 0.10 0.05 0.01
1 2.706 3.841 6.635
2 4.605 5.991 9.210
3 6.251 7.815 11.345
4 7.779 9.488 13.277
5 9.236 11.070 15.086
6 10.645 12.592 16.812
7 12.017 14.067 18.475
8 13.362 15.507 20.090
9 14.684 16.919 21.666
10 15.987 18.307 23.209
15 22.307 24.996 30.578
20 28.412 31.410 37.566
30 40.256 43.773 50.892

4. Relation to Other Distributions

The chi-squared distribution sits at the centre of the normal-theory sampling distributions, and most of the others are built from it.

Table 3. Relations to other distributions.

Distribution Relation Note
Normal $Z^2 \sim \chi^2_1$ The case $k = 1$
Exponential $\chi^2_2$ is exponential with mean 2 The case $k = 2$
Gamma $\chi^2_k$ is gamma with shape $k/2$ and scale 2 The general form of the density
Student t $Z / \sqrt{V/k}$ with $V \sim \chi^2_k$ independent of $Z$ The chi-squared is the denominator
F $(V_1/k_1) / (V_2/k_2)$ with $V_1, V_2$ independent A ratio of two chi-squared variables
Noncentral chi-squared Sum of squares of normals with nonzero means Used for the power of the tests below

The first row can be checked against Table 2. The two-sided 5 percent point of the standard normal is 1.96, and $1.96^2 = 3.8415$, which is the 5 percent point of $\chi^2_1$. A two-sided test on a normal mean and a one-sided test on its square are the same test.

5. Role in Sampling

5.1. Sample Variance of a Normal Population

For $x_1, \ldots, x_n$ drawn independently from $N(\mu, \sigma^2)$, with sample mean $\bar{x}$ and sample variance $s^2$, the scaled sample variance is chi-squared with one degree of freedom fewer than the sample size, and it is independent of $\bar{x}$.

$$\frac{(n-1)s^{2}}{\sigma^{2}} \sim \chi^2_{n-1} \hspace{19em} (7)$$

The degree of freedom that is lost is the one spent estimating $\mu$. The deviations $x_i - \bar{x}$ sum to zero by construction, so only $n-1$ of them can be chosen freely, and the sum of their squares behaves like a sum of $n-1$ independent squares rather than $n$. That the result is exactly chi-squared, and exactly independent of the mean, is Cochran's theorem [2].

Inverting equation (7) gives the confidence interval for a normal variance, which is asymmetric because the distribution is.

$$\left[ \frac{(n-1)s^{2}}{\chi^2_{n-1, \alpha/2}}, \ \frac{(n-1)s^{2}}{\chi^2_{n-1, 1-\alpha/2}} \right] \hspace{19em} (8)$$

5.2. Degrees of Freedom

Across every use of the distribution, the degrees of freedom count the quantities that are free to vary once the constraints are imposed, and each parameter estimated from the same data removes one more. In equation (7) the single constraint is the estimated mean; in the tests of section 6 the constraints come from the totals the fitted counts must reproduce. Getting this count wrong does not make the statistic wrong; it makes the reference distribution wrong, which is harder to notice.

6. Tests Built on the Distribution

6.1. Goodness of Fit

Given counts $O_1, \ldots, O_m$ falling into $m$ cells and the counts $E_1, \ldots, E_m$ that a hypothesis expects, Pearson's statistic measures the gap [3].

$$X^{2} = \sum_{j=1}^{m} \frac{(O_j - E_j)^{2}}{E_j} \hspace{19em} (9)$$

Under the hypothesis, each term is roughly a squared standardised deviation, so the sum is roughly a sum of squared standard normals and equation (1) applies. With no parameter estimated from the data the degrees of freedom are $m - 1$, the one constraint being that the expected counts total the observed count.

For 300 rolls of a die giving 43, 52, 54, 61, 48 and 42, every expected count is 50 and the statistic is 5.160 on 5 degrees of freedom. Table 2 gives 11.070 as the 5 percent point, so the counts are unremarkable; the exact upper-tail probability is 0.397.

The approximation behind the test is the normal approximation to each cell count, and it fails when the expected counts are small. The usual working rule is that every expected count should be at least 5.

6.2. Independence in a Contingency Table

For a table of counts with $r$ rows and $c$ columns, the hypothesis that the row and column classifications are independent predicts each cell from the margins alone, and equation (9) is applied to those predictions.

$$E_{ij} = \frac{R_i C_j}{n} \hspace{19em} (10)$$

The degrees of freedom follow section 5.2. The table has $rc$ cells, and the row and column proportions estimated from the margins remove $(r-1) + (c-1)$ of them, leaving $rc - 1 - (r-1) - (c-1) = (r-1)(c-1)$.

A two-by-two table with rows 38, 62 and 51, 49 has every expected count equal to 44.5 or 55.5, a statistic of 3.421 on 1 degree of freedom, and an upper-tail probability of 0.064. Against the 3.841 of Table 2 the difference between the two rows is not significant at the 5 percent level.

References

[1] Wilson, E. B., & Hilferty, M. M. (1931). The Distribution of Chi-Square. Proceedings of the National Academy of Sciences, 17(12), 684–688.
[2] Cochran, W. G. (1934). The Distribution of Quadratic Forms in a Normal System, with Applications to the Analysis of Covariance. Mathematical Proceedings of the Cambridge Philosophical Society, 30(2), 178–191.
[3] Pearson, K. (1900). On the Criterion that a Given System of Deviations from the Probable in the Case of a Correlated System of Variables is Such that it Can be Reasonably Supposed to have Arisen from Random Sampling. The London, Edinburgh, and Dublin Philosophical Magazine and Journal of Science, 50(302), 157–175.
[4] Johnson, N. L., Kotz, S., & Balakrishnan, N. (1994). Continuous Univariate Distributions (Vol. 1, 2nd ed.). Wiley. ISBN 978-0-471-58495-7.


Appendix A. Terminology

  • Cell: one class of a categorical classification, holding a count.
  • Contingency table: a table of counts cross-classified by two categorical variables.
  • Degrees of freedom: the number of quantities free to vary once the constraints on them are imposed; the parameter of the chi-squared distribution.
  • Excess kurtosis: the fourth standardised moment less 3, so that the normal distribution has the value 0.
  • Margin: a row total or a column total of a table of counts.
  • Moment generating function: $E[e^{tX}]$ as a function of $t$, whose derivatives at the origin are the moments.
  • Skewness: the third standardised moment, zero for a symmetric distribution.
  • Support: the set of values a distribution gives positive probability to.
  • Survival function: one minus the distribution function, that is the upper-tail probability.

Appendix B. Derivations

B.1. Square of a Normal Variable

The construction in equation (1) starts from standard normal variables, but a measurement rarely arrives standardised. The theorem below states the general case.

Theorem. Let $X$ be a continuous random variable with $X \sim N(\mu, \sigma^{2})$ and $\sigma \gt 0$. Then the squared standardised deviation follows the chi-squared distribution with one degree of freedom.

$$Y = \frac{(X - \mu)^{2}}{\sigma^{2}} \sim \chi^2_1 \hspace{19em} (11)$$

Proof. Put $Z = (X - \mu)/\sigma$. A linear transform of a normal variable is normal, and this one has mean 0 and variance 1, so $Z \sim N(0, 1)$ and $Y = Z^{2}$.

Being a square, $Y$ cannot be negative, so $F_Y(y) = 0$ for $y \le 0$. For $y \gt 0$ the event $Y \le y$ is the event $-\sqrt{y} \le Z \le \sqrt{y}$, so the distribution function of $Y$ follows from that of $Z$, written $\Phi$, the second step using the symmetry of the standard normal.

$$F_Y(y) = \Phi(\sqrt{y}) - \Phi(-\sqrt{y}) = 2\Phi(\sqrt{y}) - 1 \hspace{19em} (12)$$

Differentiate with respect to $y$. The chain rule contributes the derivative of $\sqrt{y}$, which is $1/(2\sqrt{y})$, and $\Phi' = \phi$ is the standard normal density $\phi(z) = e^{-z^{2}/2}/\sqrt{2\pi}$.

$$f_Y(y) = 2 \phi(\sqrt{y}) \cdot \frac{1}{2\sqrt{y}} = \frac{1}{\sqrt{2\pi}} y^{-1/2} e^{-y/2} \hspace{19em} (13)$$

What remains is to recognise equation (13). Setting $k = 1$ in equation (2) gives the density $y^{-1/2} e^{-y/2} / \left( 2^{1/2}\Gamma(1/2) \right)$, and $\Gamma(1/2) = \sqrt{\pi}$ makes that constant $\sqrt{2}\sqrt{\pi} = \sqrt{2\pi}$. The two densities agree on $y \gt 0$ and both vanish elsewhere, so $Y \sim \chi^2_1$. $\blacksquare$

Read together with equation (5), the theorem is what makes the family reachable from measurements rather than from standard normal variables: standardising and squaring $n$ independent normal observations gives $n$ independent $\chi^2_1$ variables, whose sum is $\chi^2_n$.

B.2. Moment Generating Function

For a single square, substitute $u = z\sqrt{1-2t}$ in the defining integral. The substitution is legitimate only for $t \lt 1/2$, which is where the exponent stays negative and the integral converges.

$$E\left[ e^{tZ^{2}} \right] = \int_{-\infty}^{\infty} \frac{1}{\sqrt{2\pi}} e^{tz^{2}} e^{-z^{2}/2} dz = \frac{1}{\sqrt{1-2t}} \int_{-\infty}^{\infty} \frac{e^{-u^{2}/2}}{\sqrt{2\pi}} du = (1-2t)^{-1/2} \hspace{19em} (14)$$

The remaining integral is the total mass of the standard normal density and equals 1. Since the $Z_i$ in equation (1) are independent, the moment generating function of their sum is the product of $k$ such factors, which is equation (3). Equation (5) is the same statement read backwards: the product of $(1-2t)^{-m/2}$ and $(1-2t)^{-n/2}$ is $(1-2t)^{-(m+n)/2}$.

B.3. Mean and Variance

Expand equation (3) about the origin, or differentiate it twice. The first two derivatives at $t = 0$ give the first two raw moments.

$$M'(t) = k(1-2t)^{-k/2 - 1}, \qquad M''(t) = k(k+2)(1-2t)^{-k/2 - 2} \hspace{19em} (15)$$

Setting $t = 0$ gives $E[X] = k$ and $E[X^2] = k(k+2)$, so the variance is $k(k+2) - k^2 = 2k$, which is equation (4).

B.4. Loss of One Degree of Freedom

Write the sum of squared deviations from the true mean and add and subtract $\bar{x}$ inside each square. The expansion has three pieces: the sum of squared deviations from $\bar{x}$, a cross term, and $n(\bar{x} - \mu)^2$.

$$\sum_{i=1}^{n} (x_i - \mu)^{2} = \sum_{i=1}^{n} (x_i - \bar{x})^{2} + 2(\bar{x} - \mu)\sum_{i=1}^{n}(x_i - \bar{x}) + n(\bar{x} - \mu)^{2} \hspace{19em} (16)$$

The cross term vanishes because the deviations from $\bar{x}$ sum to zero, leaving two pieces. Dividing by $\sigma^2$, the left side is a sum of $n$ squared standard normals and so is $\chi^2_n$. The last term is $\left( (\bar{x}-\mu)/(\sigma/\sqrt{n}) \right)^2$, a single squared standard normal, and so is $\chi^2_1$. Cochran's theorem [2] says that the two terms on the right are independent and each chi-squared, so the degrees of freedom subtract and the first term is $\chi^2_{n-1}$. That first term is $(n-1)s^2/\sigma^2$, which is equation (7).

Appendix C. Computation

The distribution and its inverse come from scipy.stats.chi2. The survival function sf gives the upper tail directly and is preferred over 1 - cdf, which loses precision far out in the tail, while isf inverts it and produces the entries of Table 2.

# Python
from scipy import stats

print(stats.chi2.isf(0.05, df=5))       # upper 5 percent point
print(stats.chi2.sf(5.16, df=5))        # upper tail probability of an observed statistic
print(stats.chi2.stats(df=5, moments='mv'))
11.070497693516355
0.3966674666097388
(np.float64(5.0), np.float64(10.0))

The two tests of section 6 are each one call, and both return the statistic with its upper-tail probability.

# Python
import numpy as np
from scipy import stats

print(stats.chisquare(f_obs=np.array([43, 52, 54, 61, 48, 42])))
statistic, p_value, degrees, expected = stats.chi2_contingency(np.array([[38, 62], [51, 49]]),
                                                               correction=False)
print(round(statistic, 4), degrees, round(p_value, 4))
Power_divergenceResult(statistic=np.float64(5.16), pvalue=np.float64(0.3966674666097388))
3.4214 1 0.0644

Two defaults are worth knowing. stats.chisquare assumes equal expected counts unless f_exp is given, and it takes the degrees of freedom as $m - 1$ unless ddof says how many parameters were estimated. stats.chi2_contingency applies Yates's continuity correction by default on a two-by-two table, so reproducing the uncorrected statistic of section 6.2 needs correction=False.

Our Score
Click to rate this post!
[Total: 1 Average: 3]
Visited 21 times, 1 visit(s) today

Leave a Comment

Your email address will not be published. Required fields are marked *