Try   HackMD

A.3.5 Normal(Gaussian) Distribution

定義

一個 real-valued 的 random variable

X 如果是 normal (Gaussian) distributed,且它的 mean
=μ
、variance
=σ2
,那我們就用
N(μ,σ2)
表示。

normal (Gaussian) distributed 的條件是它的 probability density function 滿足:

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

更詳細的定義和證明可參考下方「證明」小節。

normal distribution 是 continuous probability distribution 的一種,那麼為什麼稱作 "normal",是因為許多隨機的現象都會滿足如下圖這樣的 bell-shaped 分佈:

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

許多自然界的現象都可以被看作這種分佈的不同版本,每一種之間只有一點點不同,差異在於作為 typical value

μ 可能不一樣。

如果把

μ 看作 typical value,那麼
σ
的意思就變成了「有多少 instances 會在這個 prototypical(典型的)值周遭變化」。

從上面這個圖中我們可以看到和

μ 距離(不論正負)差是多少
σ
的比例各是多少,像是:

68.2% 會落在
(μσ,μ+σ)

95.5% 會落在
(μ2σ,μ+2σ)

如果是分佈在距離

3σ 之內,那麼機率達到 0.99,寫成數學式也就是:

P{|xμ|<3σ}0.99

實務上如果

x 在距離
μ 3σ
之外(也就是
x<μ3σ
x>μ+3σ
),我們令
p(x)0

證明

下圖中匡起來的地方是 normal distribution 的完整定義,首先我們先來證明這個

f(x) 滿足作為一個 pdf 的 properties。

作為一個 pdf 的 properties 定義在右方藍色字的地方,有三點,其中我們只需要證明第二點。

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

接著用 mgf 去確認

f(x) 中的
μ
σ
確實是
X
的 mean 和 variance:

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

從這裡我們也得到:

normal distribution 的 mgf 為:

M(t)=eμt+σ2t22

例子

從 pdf 推 mgf

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

從 mgf 推 pdf

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

特例:unit normal distribution

如果:

mean

=0,variance
=1

我們將這樣的 normal distribution 稱作 unit normal distribution

N(0,1)unit normal
Z

或是另一種說法,如果我們有一個 random variable

X
X
是 normally distributed with parameters
μ,σ2
(i.e.
XN(μ,σ2)
),那麼:

if XN(μ,σ2),Z=Xμσthen ZN(0,1)

這樣的做法,即下方會講的 z-normalization。

如果我們把

μ=0,σ2=1 代入原本 normal distribution 的 pdf,就會得到:

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

除此之外,如果

ZN(0,1),則
Z
的 cumulative distribution function (cdf,也就是 distribution function) 為:

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

我們通常會把 standard normal random variable 的 cdf 用

Φ(z) 表示。

特性

XN(μ,σ2)
Y=aX+b
,則:
YN(aμ+b,a2σ2)

簡單推導如下:

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

X1,X2,...,Xn: independent normal variables,
XiN(μi,σi2)

Y=X1+X2+...+Xn
Y=N(μ,σ2)

Y 亦為 normal,且
μ=iμiσ2=iσi2

independent normal variables 的和也是 normal 的

證明如下:

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

關於 moment generating function (mgf) 的更詳細的介紹,有興趣可以參考筆記「補充:moment generating function (mgf)」的內容。

打星號處證明如下:

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

z-normalization

z-normalization,又稱作 z-score normalizationstandardization,是一種把 mean

μ 轉換成
0
、 standard deviation
σ
轉換成
1
的技巧。

這麼做的目的是為了讓單位、規模不同的 data sets 之間可以去做比較。

定義

X=N(μ,σ2),則
X
的 z-normalization 定義為:

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

這樣一來,

|Z| 的值就是以 standard deviaiton 為單位,
X
μ
之間的距離。

定理

A.44 的定義衍伸出來的定理是,如果有一個
X=N(μ,σ2)
,且
Z
又滿足
ZXμσ
,則
ZN(0,1)

定理的數學式與證明如下:

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

例子

偷懶用 chatgpt 來產生的例子:

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

每個 data point 的 z-score

zi,代表這個 data point 比 mean 多或少幾個 standard deviation。

舉例來說:

z10.70

代表的是第一個 data points(原值為
4
)比
μ
0.7
σ

μ=5.240.7σ=40.7×1.72

central limit theorem (CLT)

  • CLT 有很多種版本。課本只很簡略地講了點,由於我寫一寫發現關於 CLT 的篇幅太長,所以只將課本有講到的部分寫在這裡,其他改放到後面另一篇筆記「補充:CLT」。

X1,X2,...,Xn: iid random variables
每個
Xi,i=1,...,n
的 mean 皆為
μ
, variance 皆為
σ2<

  • 因為我們從同個 population 中取這些 samples,且它們為 iid,意思就是每個 sample 有相同的 distribution(也就等同有相同的 mean 和 variance),且彼此之間互不影響。
  • 我們會規範
    σ2<
    是因為,即使大多數的 distribution 的 variance 都是 finite,但是也有 distribution 有 infinite variance,例如 Cauchy distribution。

CLT 在說的是:

N 很大時:
X1+X2+...+XN

的 distribution 會接近
N(Nμ,Nσ2)

舉例來說,如果我們的

X 是 binomial,且 parameters 為
(N,p)

意思也就是,如果我們執行

N 次獨立的 Bernoulli trials,且 success 的機率為
p
,那麼這
N
次裡的總 succes 次數就是 binomial distributed,我們把代表 success 次數的 random variable 令為
X

也可以說

X 就是
N
次 Bernoulli trials 的和(因為結果是 success 的話會加一,如果 fail 則是加零,所以總和也會等同於 success 次數。)

那麼這樣的

X 會滿足:

XNpNp(1p)N(0,1)

N(0,1): unit normal

CLT 可以應用在讓電腦產生 normally distributed random variables,programming languages 會有可以在

[0,1] 之間產生 uniformly distributed (pseudo-)random numbers 的 subroutines。

如果我們用

Ui 來代表這樣的 random variables,舉個例子來看看 CLT 會帶來什麼樣的結果,我們會得到:

i=112Ui6N(0,1)

理由見下圖:

image

最後,如果我們說

XtN(μ,σ2),則 estimated sample mean

m=t=1NXtN

也會是 normal,且 mean 為

μ,variance 為
σ2N
(即
N(μ,σ2N)
)。

意思是:

我們由一個 normal distribution 中取

N 個 sample,這些 sample 的 mean
m
本身也是一個 random variable(由 random variables 組成的 function 也會是一個 random variable)

那對於這個 sample mean

m,如果我們去看他的 distribution,就也會是 normal,且滿足上述 mean 和 variance 的結果。

簡單推導過程如下:

image

例子:

image

參考資料

  • Hogg,Tanis,Zimmerman, Probability and Statistical Inference, 9th ed(2015), p.105-107, 110