贝叶斯课后习题(五)贝叶斯决策
贝叶斯决策
- 有x服从
B
(
3
,
θ
)
B(3,\theta)
B(3,θ)
- 因为先验在例题中提到是
U
(
0
,
0.12
)
U(0,0.12)
U(0,0.12),所以假设为
[
0
,
0.12
]
[0,0.12]
[0,0.12]上的均匀分布
π ( θ ) = 1 0.12 , 0 < θ < 0.12 \pi(\theta)=\frac1{0.12},0<\theta<0.12 π(θ)=0.121,0<θ<0.12
可有x的概率分布函数 p ( x ∣ θ ) = C 3 x θ x ( 1 − θ ) 3 − x p(x|\theta)=C_3^x\theta^x(1-\theta)^{3-x} p(x∣θ)=C3xθx(1−θ)3−x
可有联合密度函数 h ( x , θ ) = p ( x ∣ θ ) π ( θ ) = 1 0.12 C 3 x θ x ( 1 − θ ) 3 − x h(x,\theta)=p(x|\theta)\pi(\theta)=\frac1{0.12}C_3^x\theta^x(1-\theta)^{3-x} h(x,θ)=p(x∣θ)π(θ)=0.121C3xθx(1−θ)3−x
可有x的边缘分布 m ( x ) = 1 0.12 ∫ 0 0.12 h ( x , θ ) d θ = 1 0.12 C 3 x ∫ 0 0.12 θ x ( 1 − θ ) 3 − x d θ m(x)=\frac1{0.12}\int_0^{0.12}h(x,\theta)d\theta=\frac1{0.12}C_3^x\int_0^{0.12}\theta^x(1-\theta)^{3-x}d\theta m(x)=0.121∫00.12h(x,θ)dθ=0.121C3x∫00.12θx(1−θ)3−xdθ
可有后验分布 π ( θ ∣ x ) = h ( x , θ ) m ( x ) = θ x ( 1 − θ ) 3 − x ∫ 0 0.12 θ x ( 1 − θ ) 3 − x d θ \pi(\theta|x)=\frac{h(x,\theta)}{m(x)}=\frac{\theta^x(1-\theta)^{3-x}}{\int_0^{0.12}\theta^x(1-\theta)^{3-x}d\theta} π(θ∣x)=m(x)h(x,θ)=∫00.12θx(1−θ)3−xdθθx(1−θ)3−x
带入x有:
p i ( θ ∣ 0 ) = θ 0 ( 1 − θ ) 3 − 0 ∫ 0 0.12 θ 0 ( 1 − θ ) 3 − 0 d θ = 9.99 ( 1 − θ ) 3 pi(\theta|0)=\frac{\theta^0(1-\theta)^{3-0}}{\int_0^{0.12}\theta^0(1-\theta)^{3-0}d\theta}=9.99(1-\theta)^3 pi(θ∣0)=∫00.12θ0(1−θ)3−0dθθ0(1−θ)3−0=9.99(1−θ)3
p i ( θ ∣ 1 ) = θ 1 ( 1 − θ ) 3 − 1 ∫ 0 0.12 θ 1 ( 1 − θ ) 3 − 1 d θ = 163.9387 θ ( 1 − θ ) 2 pi(\theta|1)=\frac{\theta^1(1-\theta)^{3-1}}{\int_0^{0.12}\theta^1(1-\theta)^{3-1}d\theta}=163.9387\theta(1-\theta)^2 pi(θ∣1)=∫00.12θ1(1−θ)3−1dθθ1(1−θ)3−1=163.9387θ(1−θ)2
p i ( θ ∣ 2 ) = θ 2 ( 1 − θ ) 3 − 2 ∫ 0 0.12 θ 2 ( 1 − θ ) 3 − 2 d θ = 1907.85 θ 2 ( 1 − θ ) pi(\theta|2)=\frac{\theta^2(1-\theta)^{3-2}}{\int_0^{0.12}\theta^2(1-\theta)^{3-2}d\theta}=1907.85\theta^2(1-\theta) pi(θ∣2)=∫00.12θ2(1−θ)3−2dθθ2(1−θ)3−2=1907.85θ2(1−θ)
p i ( θ ∣ 3 ) = θ 3 ( 1 − θ ) 3 − 3 ∫ 0 0.12 θ 3 ( 1 − θ ) 3 − 3 d θ = 19290.12346 θ 3 pi(\theta|3)=\frac{\theta^3(1-\theta)^{3-3}}{\int_0^{0.12}\theta^3(1-\theta)^{3-3}d\theta}=19290.12346\theta^3 pi(θ∣3)=∫00.12θ3(1−θ)3−3dθθ3(1−θ)3−3=19290.12346θ3
- 因为先验在例题中提到是
U
(
0
,
0.12
)
U(0,0.12)
U(0,0.12),所以假设为
[
0
,
0.12
]
[0,0.12]
[0,0.12]上的均匀分布
- 有损失函数
L
(
θ
,
d
)
=
e
c
(
θ
−
d
)
−
c
(
θ
−
d
)
−
1
L(\theta,d)=e^{c(\theta-d)}-c(\theta-d)-1
L(θ,d)=ec(θ−d)−c(θ−d)−1
- 分情况:求导数
L
′
(
θ
,
d
)
=
c
e
c
(
θ
−
d
)
−
c
L'(\theta,d)=ce^{c(\theta-d)}-c
L′(θ,d)=cec(θ−d)−c
{ θ − d > 0 , c > 0 L ′ ( θ , d ) > 0 θ − d > 0 , c < 0 L ′ ( θ , d ) > 0 θ − d < 0 , c > 0 L ′ ( θ , d ) < 0 θ − d < 0 , c < 0 L ′ ( θ , d ) < 0 \begin{cases}\theta-d>0,c>0&L'(\theta,d)>0\\\theta-d>0,c<0&L'(\theta,d)>0\\\theta-d<0,c>0&L'(\theta,d)<0\\\theta-d<0,c<0&L'(\theta,d)<0\end{cases} ⎩⎪⎪⎪⎨⎪⎪⎪⎧θ−d>0,c>0θ−d>0,c<0θ−d<0,c>0θ−d<0,c<0L′(θ,d)>0L′(θ,d)>0L′(θ,d)<0L′(θ,d)<0
可以看到,重点都是 L ( θ , d ) = L ( θ − d = 0 ) = 0 L(\theta,d)=L(\theta-d=0)=0 L(θ,d)=L(θ−d=0)=0 - 画图自己画吧
- 有贝叶斯估计为 E θ ∣ x [ L ( θ , d ) ] = E θ ∣ x [ e c ( θ − d ) − c ( θ − d ) − 1 ] = e − c d E [ e c θ ∣ x ] − c E [ θ ∣ x ] + c d − 1 E^{\theta|x}[L(\theta,d)]=E^{\theta|x}[e^{c(\theta-d)}-c(\theta-d)-1]\\=e^{-cd}E[e^{c\theta}|x]-cE[\theta|x]+cd-1 Eθ∣x[L(θ,d)]=Eθ∣x[ec(θ−d)−c(θ−d)−1]=e−cdE[ecθ∣x]−cE[θ∣x]+cd−1
- 有样本的分布函数
p
(
x
‾
∣
θ
)
=
∏
i
=
1
n
p
(
x
i
∣
θ
)
=
(
2
π
)
−
n
2
e
−
1
2
∑
i
=
1
n
x
i
2
+
n
θ
x
‾
−
n
2
θ
2
p(\overline{x}|\theta)=\prod_{i=1}^np(x_i|\theta)=(2\pi)^{-\frac n2}e^{-\frac12\sum_{i=1}^nx_i^2+n\theta\overline{x}-\frac n2\theta^2}
p(x∣θ)=∏i=1np(xi∣θ)=(2π)−2ne−21∑i=1nxi2+nθx−2nθ2
可有后验分布 π ( θ ∣ x ‾ ) ∝ p ( x ‾ ∣ θ ) π ( θ ) ∝ e − n 2 ( θ − x ‾ ) 2 \pi(\theta|\overline{x})\varpropto p(\overline{x}|\theta)\pi(\theta)\varpropto e^{-\frac n2(\theta-\overline{x})^2} π(θ∣x)∝p(x∣θ)π(θ)∝e−2n(θ−x)2
可以看到后验分布服从正态分布 θ ∣ x ‾ − N ( x ‾ , 1 n ) \theta|\overline{x}-N(\overline{x},\frac1n) θ∣x−N(x,n1)
先求导
- 分情况:求导数
L
′
(
θ
,
d
)
=
c
e
c
(
θ
−
d
)
−
c
L'(\theta,d)=ce^{c(\theta-d)}-c
L′(θ,d)=cec(θ−d)−c