Random Variable
Definition
Random variable 是將 sample space 中的 outcome 映射到 real line 的函數。
X:S→R
也就是把隨機實驗的結果轉成一個可以分析的數值。
Types of Random Variables
Discrete Random Variable: possible values 可以一一列舉
Continuous Random Variable: possible values 為連續數值
Discrete Random Variables
Expected Value
Expected value 描述 distribution 的 center。
μ=E(X)=∑xxP(X=x)
Variance
Variance 描述 distribution 的 dispersion。
σ2=Var(X)=E[(X−μ)2]
更常用的計算式:
Var(X)=E(X2)−[E(X)]2=E(X2)−μ2
Moments
r-th moment: E(Xr)=∑xxrP(X=x)
- First Moment: E(X)=μ
- Second Moment: E(X2)=μ2+σ2
Expectation of a Function
對函數 g(X):
E[g(X)]=∑xg(x)P(X=x)
Properties of Expectation and Variance
若 a,b,c 為 constants:
-
Constant: E(c)=c,Var(c)=0
-
Linearity of Expectation: E(aX+bY)=aE(X)+bE(Y)
-
Variance under Scaling: Var(aX)=a2Var(X)
-
Adding a Constant: Var(aX+c)=a2Var(X)
-
General Variance Formula: Var(aX+bY)=a2Var(X)+2abCov(X,Y)+b2Var(Y)
- 若 X,Y independent: Cov(X,Y)=0
- Var(aX+bY)=a2Var(X)+b2Var(Y)
Covariance and Correlation
不考
-
Covariance: Cov(X,Y)=E[(X−μX)(Y−μY)]
-
Correlation coefficient: ρX,Y=Var(X)Var(Y)Cov(X,Y)
-
X,Y independent: Cov(X,Y)=0
Bernoulli Random Variable
Bernoulli trial 只有兩種 outcome: Success/Failure
Y={1,0,successfailure
若 success probability 為 p: Y∼Bernoulli(p)
且:
P(Y=1)=p
P(Y=0)=1−p
合併寫成:
P(Y=y)=py(1−p)1−y,y=0,1
- Mean: E(Y)=p
- Variance: Var(Y)=p(1−p)
- Odds=1−pp
Binomial Random Variable
- 固定 trial 次數 n
- 每次只有 success / failure
- trials independent
- 每次 success probability 都相同為 p
- X = n 次 trials 中 success 的次數
若符合: X∼Binomial(n,p)
則: P(X=x)=(xn)px(1−p)n−x
- E(X)=np
- Var(X)=np(1−p)
- Standard deviation: SD(X)=np(1−p)
記憶方式: Binomial as a Sum of Bernoulli Variables (n 次獨立)