Try   HackMD

Introduction

這篇主要在講我們的期望值

Expectation of a Random Variable

這些名詞所代表的東西是一樣的,都是表示期望值 :

  • expected value
  • mean
  • first moment

直觀的來看,就是代表這個函式的中心

如果用數學表示 :

μx=E(X)=x dF(x) {Σx xf(X), X is discrete xf(x) dx, X is continuous

常見 distribution 的
EX

接下來就用常見的 distribution 當作例子 :

  • XBernoulli(p)x{0,1}
    EX=0×(1p)+1×p=p

  • XBIN(n,p)x{0,1,......,n}
    EX=Σx=0n xCxnpx(1p)nx=np

  • XUNIF(p)
    EX=abxf(x)dx=a+b2

  • XPOI(λ)
    EX=...... by def=λ

  • XEXP(β)
    EX=...... by def=β

  • XGamma(α,β)
    EX=...... by def=αβ

基礎公式

先令

Y=r(X), Z=r(X, Y)

  • EY=E(r(x))=r(x)dFX(x)
  • EZ=E(r(X, Y))=r(x, y)f(x, y) dxdy

證明過程如下 :

EY :
我們在已知
X
的分布的情況下要求出
EY

Let Y=r(X)

E(Y)=ydFY(y) y =E(r(X))=r(x)dFX(x)使 x 

Examples

Question 1

question :

XUNIF(0, 1), Y=r(X)=eX, 求出
EY

solution :
首先把題目做解析

X 可以看出 :
fX={1, 0x10, otherwise

Y
可以看出 :
x=r1(y)=ln(y)

然後有 2 種解題方式 :

  • method 1 : 找出

    y 的分佈
    fY(y)=fX(ln(y)) d ln(y)dy=1×1y=1y, 1ye

    EY=1eyfY(y)dy=1ey1ydy=[ y ]1e=e1

  • method 2 : lazy, by fomula

    EY y =Er(X) x =\colorred0\colorred1r(x)f\colorredx\colorred(x)dx=01ex×1=[ ex ]01=e1

Question 2

question :

XUNIF(0, 1), Y=max(x, 1x), 求出
EY

solution :
有 2 種解題方式 :

  • method 1 : 找出

    y 的分佈
    FY(y)=P(Yy)=P(max(x, 1x)y)=P(xy & (1x)y)=P((1y)xy)

    =1yyfX(x)dx=[ x ]1yy=2y1, 12y1

    因為上面做出來的是
    cdf
    ,我們要得知
    EY
    是要用
    pdf
    ,因此要進行微分
    fY(y)=ddyFY(y)=yEY=121yfY(y)dy=1212y dy=34

  • method 2 : lazy, by fomula
    從題目可以先得知可能會需要拆開來看,因此我們先做表格確認一下

    x
    y=r(x)
    13
    23\colorgreen1x
    23
    23\colorgreenx

    從表格可以看出我們會需要拆成

    2 段來計算
    {0<x<12:1x12<x<1:x

    EY=Er(X)=\colorpurple0\colorpurple1\colorpurpler(x)fX(x)dx
    =012(1x)fX(x)dx+121(x)fX(x)dx

    =012(1x)dx+121(x)dx=34

Question 3

question :

(X, Y)uniform distribution\colorpurplef(x, y)=1 on the unit square\colorblue[0, 1]×[0, 1], Z=r(x, y)=X2+Y2,
EZ

solution :
有 2 種解題方式 :

  • method 1 : 找出

    z 的分佈
    ..., ...

  • method 2 : lazy, by fomula

    EZ=Er(X, Y)=0101(x2+y2)f(x, y) dxdy
    =0101(x2+y2) dxdy=23

Properties of Expectation

基礎公式

X1, ..., Xn 是 random variables,且
a1, ..., an
是常數
這時
E(ΣiaiXi)=ΣiaiE(Xi)

證明過程如下 :

E(a1x1+a2x2)=(a1x1+a2x2)f(x1, x2)dx1dx2
=\colororange(a1x1)f(x1, x2) dx2\colororangedx1+\colororange(a2x2)f(x1, x2) dx1\colororangedx2

=(a1x1)f(x1, x2) dx2 dx1+(a2x2)f(x1, x2) dx1 dx2

=a1[ x1f1(x1) dx1]=EX1+a2[ x2f2(x2) dx2]=EX2

=a1EX1+a2EX2


X1, ..., Xn 是 independent random variables
這時
E(ΠinXi)=ΠinE(Xi)

證明過程如下 :

E(x1x2)=(x1x2) f(x1, x2)\colorredindependent dx1dx2
=x1\colororangex2f1(x1)\colororangef2(x2) dx1dx2把橘色部分丟到外面

=x2f2(x2)[ x1f1(x1) dx1]=EX1dx2

=x2f2(x2)EX1 dx2=EX1[ x2f2(x2) dx2]=EX2

=EX1EX2

Variances and Covariance

基礎公式

先令

X 是一個 random variable,並且它的 mean 跟 variance 分別為
μ, σ2(σX2, V(X), VX)

並且
σ2
的定義為 :
σ2=E(Xμ)\colorred2=(xμ)2dF(x)

另外 variance 會遵循以下特性 :

  1. V(X)=E(X2)μ2
  2. V(aXb)=a2V(X), for a,bconstant
  3. V(Σi=1n aiXi)=Σi=1n \colorredai2V(Xi), for X1, ..., Xn are independent, and aconstant

證明過程如下 :

  1. VX=E(xμ)2=E(x22xμ+μ2)=......=EX2μ2
  2. V(ax+b)=E[ (ax+b)E(ax+b) ]2=......=a2VX
    數學上
    V(ax+b)=V(aX)=a2VX
    直觀上
  3. V(a1x1+a2x2)=E[ a1x1+a2x2E(a1x1+a2x2) ]2=...(related to EY1Y2=EY1EY2)...

上述說的都是母體的情況,接下來這部分要講 sample mean & sample variance
先令

Xi, ..., Xn 都是相同且相互獨立的分佈
並且令
μ=E(Xi), σ2=V(Xi)

這時 :
E(Xn)=μ, V(X)=σ2n, E(Sn2)=σ2

證明過程如下 :

EXn=E(1nΣi=1n Xi)=......=μ
VXn=E[ (1nΣi=1n Xi)E(Xn) ]2=σ2n

important :
ESn2=E[ 1n1Σ(XiXn)2 ]=E[ 1n1Σ(Xi22XiXn+Xn2) ]=......=σ2


接著我們來看 covariance & correlation
先令

Xi, ..., Xn
Yi, ..., Yn
都是 random variables,並且 means 跟 standard deviation 分別為
μX, σX, μY, σY

這時 :

  • covariance :

    Cov(X, Y)=E((XμX)(YμY))=E(XY)E(X)E(Y)=E[ (XEX)(YEY) ]
    小補充 :
    Cov
    的大小代表線性關係的強度,
    Cov
    的正負代表線性關係的方向

  • correlation :

    ρ=ρX, Y=ρ(X, Y)=Cov(X, Y)\colorredρX ρY, 1ρ(X, Y)1
    假設
    Y=aX+b, a, bconstant

    這時 :
    {ρ(X, Y)=1, a>0ρ(X, Y)=1, a<0
    (下面有附上證明)
    另外,如果
    X
    Y
    是獨立的(independent)
    Cov(X, Y)=ρ=0

    證明過程如下 :

    已知

    Y=aX+b, VY=a2VX
    cov(X, Y)=cov(X, aX+b)=E[ X(aX+b) ](EX)(aEX+b)

    =E(aX2+bX)(EX)(aEX+b)=......=aσ2corr(X, Y)=1 or 1 depending on a=(aσ)sd(Y)σsd(X)


接著我們來看

2 個變數的 variance
{V(X+Y)=V(X)+V(Y)+2Cov(X, Y)V(XY)=V(X)+V(Y)2Cov(X, Y)

廣義上來說,也可以轉換成這樣 :
V(Σi aiXi)=Σi ai2V(Xi)+2ΣΣi<j aiajCov(Xi, Xj)

Examples

Question 1

question :

XBIN(n, p),  EX, VX

solution :
然後有 2 種解題方式 :

  • method 1 : by basic def

    EX=ΣX xf(x)
    VX=ΣX (xμ)2=EX2μ

  • method 2 : by scratch

    X=Σi=1n Zi, ZiiidBernoulli(p)EZi=p, VZi=p(1p)
    EX=E Σi=1n Zi=Σi=1n EZi=np\colorpurple Zi 

    VX=V Σi=1n Zi=Σi=1n VZi=np(1p)\colorpurple Zi 

Question 2

question :

XGamma(α, β),  EX, VX

solution :
然後有 2 種解題方式 :

  • method 1 : by basic def

    ......

  • method 2 : by scratch

    X=Σi=1n Zi, Ziiidexp(β)EZi=β, VZi=β2
    EX=E Σi=1α Zi=Σi=1α EZi=αβ

    VX=V Σi=1α Zi=Σi=1α VZi=αβ2

Expectation and Variances of Important Random Variables

粗體的部分是一定要記住的!!!

Distribution Mean Variance
Point mass at
a
a
0
Bernoulli
(p)
p
p(1p)
Binomial
(n, p)
np
np(1p)
Geometric
(p)
1/p
(1p)/p2
Poisson
(λ)
λ
λ
Uniform
(a, b)
(a+b)/2
(ba)2/12
Normal
(μ, σ2)
μ
σ2
Exponential
(β)
β
β2
Gamma
(α, β)
αβ
αβ2
Beta
(α, β)
α/(α+β)
αβ/((α+β)2(α+β+1))
tν
0, if ν>1
ν/(ν2), if ν>2
χp2
p
2p
Multinomial
(n, p)
np
see below
Multivariate Normal
(μ, Σ)
μ
Σ