# 補充:Bessel's correction ## 定義 在一開始我們想去定義 sample variance 時,naive 的版本為將 multiplicative factor 定為去除我們一個 sample 中的 data points 總數,也就是乘以 $\frac{1}{n}$: \begin{equation} s^2 = (\frac{1}{n})\sum_{i=1}^n(x_i - \bar{x})^2 \end{equation} 但是這樣的做法實際上會產生 bias,所以 Bessel's correction 即是將 $\frac{1}{n}$ 改為 unbiased 的版本 $\frac{1}{n-1}$,使得 variance 的定義為: \begin{equation} s^2 = (\frac{1}{n-1})\sum_{i=1}^n(x_i - \bar{x})^2 \end{equation} 也就是說,如果我們要去修正原本 naive 的版本,我們只要去乘上 $\frac{n}{n-1}$,就能使它變成一個 unbiased estimator。 - 不過當 $n$ 很大時,naive 的版本所造成的 bias 是 negligible 的。 > $\rightarrow$ 關於 sample 以及 sample variance 等內容可參考筆記 $A.2$ 的「補充:sample」。 > > $\rightarrow$ 關於 bias、unbiased estimator 等內容可參考筆記「4.3 Evaluating an Estimator: Bias and Variance」。 ## 理由 在我們計算 sample variance 時,根據定義,我們需要去計算 sample mean $\bar{x}$,這個動作就是造成我們會變成需要用 $n-1$ 的原因。 為什麼呢? 因為我們的 sample 中所有的 data points 和 sample mean 之間的 deviation 和一定為 $0$,寫成數學式以及理由如下圖:  這也就造成了一個限制,假設我們有 $n$ 個 data points $x_1,...,x_n$,它們的 residual vector 可以寫成: \begin{equation} (x_1 - \bar{x},...,x_n - \bar{x}) \end{equation} 先岔出來簡單解釋一下 residuals 的定義。 --- ### error vs residual error 和 residual 這兩個名詞都是拿來定義我們的 observed value 和一個 "true value" 之間的差距。 差異在於: - <font color = "snake">error</font> 用來定義 observed value 和 ++population 的 true value++ 之間的差距。 - <font color = "snake">residual</font> 用來定義 observed value 和 ++estimated value++ 之間的差距。 舉個例子馬上就能明白: 如果是一個 data point 和 <font color = "green">population mean</font> 之間的差距就是 ++error++,如果是 data point 和 <font color = "green">sample mean</font> 之間的差距就是 ++residual++。 在上面的例子裡,因為我們是去計算 $x_i$ 和 $\bar{x}$ 之間的差距,$\bar{x}$ 是 sample mean,而我們的 population mean 是需要去估算的某個未知值,所以才是 residual vector 而非 error vector。 --- 回到上面的 residual vector: 因為各個 data points 偏離 sample mean 的和為零,所以也就代表了我們的 ++degree of freedom 是 $n-1$ 而非 $n$++,因為當這個 vector 決定了其中 $n-1$ 個值,最後的一個就也跟著被決定。見下圖:  因此,在計算 $s^2 = (\frac{1}{n-1})\sum_{i=1}^n(x_i - \bar{x})^2$ 時,這之中的 $(x_i - \bar{x})$ 就只有 $n-1$ 項可以自由變化。想法上感覺分母從 $n$ 修正成 $n-1$ 是很合理的,實際也確實如此,如果對證明有興趣可以參考下方內容。 另外,如果我們保持使用 $n$ 作為分母,算出來的 $s^2$ 會如何呢?既然已經知道會有 bias,那它會比真正的 $\sigma^2$ 大還是小呢? $\rightarrow$ 結論是會 <font color = "red">$s^2_n$ 會小於 population variance $\sigma^2$</font> > $s^2_n$ 的下標 $n$ 表示 naive sample variance ## 證明   從代數角度證明分母換成 $n-1$ 就是 unbiased:  為什麼 naive sample variance 會 biased 直觀的想法:  > 可以想像: > > 因為每個 $x_i, \ i=1,...n$ 都是一個 sample 裡的 random variable,所以跟它們的平均之間的差距必然比和整個 population 平均的差距來的小。 # 參考資料 - wiki: - [Errors and residuals](https://en.wikipedia.org/wiki/Errors_and_residuals) - [Bessel's correction](https://en.wikipedia.org/wiki/Bessel%27s_correction) - [Bias of an estimator](https://en.wikipedia.org/wiki/Bias_of_an_estimator#:~:text=The%20sample%20variance%20of%20a,a%20different%20scale%20factor%2C%20resulting)
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up