# A.3.6 Chi-Square Distribution 因為我的機器學習課本寫得很簡略,所以關於更詳細的 Chi-Square Distribution 內容我會寫在「補充:Chi-Square Distribution」,可按需要參考,而這篇筆記的內容就只會包含課本的簡略版。 --- ## 定義 :::info 如果 $Z_i$ 是 independent unit normal random variables(i.e. $Z_i \sim N(0,1)$),則: \begin{equation} X = Z_1^2 + Z_2^2 + \ ... \ + Z_n^2 \end{equation} 為 <font color = "blue">chi-square with $n$ degrees of freedom</font>,即 ==$X \sim \chi_n^2$== ::: > 也就是說: > > 如果我們有一個 random variable $X$,它是 $n$ 個彼此獨立,且皆具 standard normal distribution 的 random variables 的和,那我們就說 $X$ 是 chi square,且有 $n$ degrees of freedom。 >> standard normal distribution 即 pdf 為 normal distribution 的 pdf 且 $\mu=0$、$\sigma^2 = 1$。 ## 特性 ### mean, variance :::success chi-square distribution 的 mean 和 variance 為: \begin{equation} E[X] = n \qquad Var(X) = 2n \end{equation} ::: > $n=$ ++standard normal random variable 的個數++ $=$ ++degree of freedom 數++ ### chi-squared distribution from normal-distributed sample ![image](https://hackmd.io/_uploads/ryFVzItUA.png) wiki 的寫法或許比較清楚: ![image](https://hackmd.io/_uploads/SJzFfUKLC.png) 課本並沒有給證明,所以我自己證了,可能沒有證得很漂亮,但步驟都有寫清楚: ![image](https://hackmd.io/_uploads/S1aCzLKI0.png) 我的證法是計算出左邊的值,證明會等於右邊的 chi-square distribution with $N-1$ degrees of freedom。 步驟為: 1. 先算 $m$ 的 distribution(最後會用到) 2. 算出 $\sum_{t=1}^N(X^t-m)^2$ 3. 代入 $(N-1)\frac{S^2}{\sigma^2}$ 4. 將結果由 chi square distribution 的定義轉換成 chi-squared 的形式 各步驟詳細如下: 1. ![image](https://hackmd.io/_uploads/Sk2XEUKUR.png) 2. ![image](https://hackmd.io/_uploads/HybwNLF8A.png) 3,4. ![image](https://hackmd.io/_uploads/BJO5VLYLR.png) > 最後 $\chi_N^2 -\chi_1^2 = \chi_{N-1}^2$ 的理由如箭頭下方藍字說明,這個 property 課本沒有。反正大意就是: > > 如果你有一個 chi-square with $N$ degrees of freedom,你可以任意拆成一個 chi-square with $k$ degrees of freedom 和 chi-square with $N-k$ degrees of freedom 相加。 > > 至於這個式子為什麼成立,我後來在同章後方的筆記「補充:random functions associated with normal distributions」中的 Thm 5.5-2 有更新,如果有興趣可以參考。