Try   HackMD

Introduction

這篇主要接續上一篇所說的
接著介紹 conditional 以及 MGF 的部分

Conditional Expectation

基礎公式

conditional expectation :

E(Y|X=x)={Σ yfY|X(y|x)discrete\colorredyfY|X(y|x) \colorreddycontinuous
用定義來看就是代表在給定
X=x
之下
小補充 :
Y
的 mean 會隨著
x
的值而改變
並且如果做成圖形,可以發現
E(Y|X=x)
是決定不同分佈之間分得多開

conditional variance :

V(Y|X=x)={Σ (yμ(x))2fY|X(y|x)discrete\colorred(yμ(x))2fY|X(y|x) \colorreddycontinuous, for μ(x)=E(Y|X=x)
小補充 :
Y
的 var 會隨著
x
的值而改變
並且如果做成圖形,可以發現
V(Y|X=x)
是決定同分佈之中有多聚集

補充 : (用回歸分析的角度來看)

假設 :

{Yi=β0+β1+ϵiϵiiidN(0, σ2)
Yt=(Yi|Xi=xi)indepN(β0+β1xi, σ2)

E(Yi|Xi=xi)=β0+β1xiY
的 mean 會受到
x
值所改變
V(Yi|Xi=xi)=σ2Y
的 var 不會受到
x
值所改變


接著我們來看

2 個變數 :
conditional expectation
if
r(x, y)
is a function of
x, y

E(r(X, Y)|X=x)={Σ r(x, y)fY|X(y|x)discrete r(x, y)fY|X(y|x)dxcontinuous

variance :

V(Y)=E[ V(Y|X) ]+V[ E(Y|X) ]
直觀一點的來看,把
V
E
都加入下標 :
V(Y)=E\colorredX[ V\colorredY(Y|X)= h(x)  conditional variance ]+V\colorredX[ E\colorredY(Y|X)= g(x)  conditional mean ]

證明過程如下 :

V(Y)=E(YEY)2=\colorgreenE(Y2)\colororange(EY)2
=\colorgreenE[ E(Y2|X) ]E[ E(Y|X) ]2(1)+\colororangeE[ E(Y|X)2 ]E[ E(Y|X) ]2(2)

\colorgreen(1): =E[ [ \colorpurpleE(\colorpurpleY2|X) ][ \colorpurpleE(\colorpurpleY|X) ]\colorpurple2 ]=E[ V(Y|X=x)]=\colorgreenE[ V(Y|X)]

\colororange(2)E(Y|X)=g(x): =Eg(x)2[ Eg(x) ]2=V[ g(x)]=\colororangeV[ E(Y|X)]

V(Y)=\colorgreenE[ V(Y|X)]+\colororangeV[ E(Y|X)]


然後我們來看最困難的部分 Iterated Expectation :
假設

X, Y 都是 random variable,並且期望值都存在
{E[ E[ Y|X ] ]=E(Y)E[ E[ X|Y ] ]=E(X)

更直觀一點的來看,我們可以把
E
都加上下標就會知道要怎麼化簡 :
E\colorredX[ E\colorredY[ Y|X ]= r(x) ]=E(Y)

廣義上來說,也可以轉換成這樣 :
E[ E[ r(X, Y)|X ] ]=E(r(X, Y))

E\colorredX[ E\colorredY[ r(X, Y)|X ]= r(x) ]=E(r(X, Y))

證明過程如下 :

首先從

EY(Y|X=x) 開始證明 :
EY(Y|X=x)=yfY|X(y|x)dy=g(x)EY(Y|X)=g(x)

接著就能得到

E[ E[ Y|X ] ]=E(Y) :
E[ E[ Y|X ] ]=E(Y)=EXEY(Y|X)

=E[ g(x) ]=g(x)fX(x)dx

=yfY|X(y|x)fX(x) dy dx=yf(x, y) dx dy=y\colorpurplef(x y) dx dy=y\colorpurplefY(y) dy=EY

Examples

Question 1

question :

XUNIF(0, 1), Y|X=xUNIF(x, 1), 求出
E(Y|X=x)

solution :
可以先從題目得知

fY|X(y|x)=11x
然後有 2 種解題方式 :

  • method 1 : 在數學上來看

    E(Y|X=x)=x1 yfY|X(y|x)dy=x1 y11xdy=1+x2固定會和 x有關

  • method 2 : 從直觀上來看

    E(Y|X=x)=1+x2

Question 2

question :

XUNIF(0, 1), Y|X=xUNIF(x, 1), 求出
EY

solution :
可以先從上一題得知

E(Y|X=x)=1+x2
然後有 2 種解題方式 :

  • method 1 : 列出所有可能性

    Y 的所有可能值 :
    12(1+x), x[0, 1]

    :fX(x)=1

    EY=01 12(1+x)fX(x)dx=34

  • method 2 : 直接用公式

    EY=E\colorredXE\colorredY(Y|X)=EX[ 12(1+x) ]=12+12EX=34

Question 3

question :

QUNIF(0, 1), X|Q=qBIN(n, q), 求出
EX, VX

solution :
先解析題目 :

QUNIF(0, 1){EQ=12VQ=112, by formula in chapter 3.4
X|Q=qBIN(n, q){E(X|Q=q)=nqV(X|Q=q)=nq(1q), by formula in chapter 3.4

接著就可以計算了 :
EX=E\colorpurpleQ[ E\colorpurpleX(X|Q) ]\colorredimportant=EQ(nQ)=nEQ=2n

VX=V\colorpurpleQ[ E\colorpurpleX(X|Q) ]+E\colorpurpleQ[ V\colorpurpleX(X|Q) ]\colorredimportant=VQ(nQ)+EQ(nQ(1Q))=n212+n(EQEQ2)

=n212+n2n(112+14)\colorredEQ2 = VQ(EQ)2

Moment Generating Function(MGF)

又被稱作 MGF 或是 Laplace transform

基礎公式

ψX(t)=E(etX)=etx dF(x)
並且
{EX=ψX(t)EX2=ψX(t)=VX+(EX)2

證明過程如下 :

  • ψX(t)=ddtetxfX(x) dx=\colorredxetxfX(x) dxt=0ψX(0)=xfX(x)dx=EX

  • ψX(t)=ddtψX(t)=ddtxetxfX(x) dx=\colorredx2etxfX(x) dxt=0ψX(0)=x2fX(x)dx=EX2


接下來這邊介紹

MGF 的一些重要特性

  • if
    Y=aX+bψY(t)=ebtψX(αt)
  • if
    X1, ..., Xn
    are
    \colorredindependent
    , and
    Y=ΣiXiψY(t)=Πi ψi(t), ϕi=MGF of Xi
  • X, Y
    are random variables, if
    ψX(t)=ψY(t)
    for all
    tX=dY

Important MGF of Commom Distribution

Distribution MGF (
ψ(t)
)
Bernoulli (
p
)
pet+(1p)
Binomial (
n, p
)
(pet+(1p))n
Poisson (
λ
)
eλ(et1)
Normal (
μ, σ
)
eμt+σ2t22
Gamma (
α, β
)
(11βt)α, t<1β

Examples

Question 1

question :

XExp(θ), f(x)=1θexθ, x>0, 求出
EX, VX

solution :

ψ(t)=Eetx=0etxf(x)dx=01θex(t1θ)dx=[ 1θθtθ1ex(t1θ) ]0=11θt=[ 1θt ]1, t0, t1θ<0
EX=[ ψ(t) ]t=0=[ (1θt)2(θ) ]t=0=θ

EX2=[ ψ(t) ]t=0=[ 2(1θt)3θ2 ]t=0=2θ2

VX=EX2(EX)2=2θ2θ2=θ2

Question 2

question :

XiiidBernoulli(p), f(x)={1, with probability =p0, with probability =1p, Y=Σi=1nxi? 求出
Y
的分佈

solution :

ψxi(t)=Eetxi=et0f(0)+et1f(1)=1p+pet
ψY(t)=Πi=1nψxi(t)=(1p+pet)n
確實是
Bin(n, p)
MGF

Question 3

question :

{X1Bin(n1, p)X2Bin(n2, p)X1X2 X1+X2 

solution :
在開始計算之前,我們可以知道 :

P(X1+X2=t)=Σ(X1+X2=t)P(X1=x1, X2=x2)
ψX1+X2(t)=Eet= ... =ψX1(t)ψX2(t)=(1p+etp)n1(1p+etp)n2=(1p+etp)n1+n2

X1+X2Bin(n1+n2, p)

Question 4

question :

XiPoi(λi), i=1, 2, ..., n, Xi is independent, Σi=1nXi?

solution :
在開始計算之前,我們可以知道 :

P(X1+X2+...+Xn=t)=Σ(X1+X2+...+Xn=t)P(X1=x1, X2=x2, ..., Xn=xn)
ψX1+...+xn(t)=Πi=1nψXi(t)=Πi=1n \colorgreeneλi(et1)Poi 的 mgf=e\colorgreen(Σi=1nλi)(et1)

X1+X2+...+Xn=Σi=1nXiPoi(Σi=1nλi)