贝叶斯课后习题(五)贝叶斯决策

贝叶斯决策

  1. 有x服从 B ( 3 , θ ) B(3,\theta) B(3,θ)
    1. 因为先验在例题中提到是 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θ)3x
      可有联合密度函数 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θ)3x
      可有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.12100.12h(x,θ)dθ=0.121C3x00.12θx(1θ)3xdθ
      可有后验分布 π ( θ ∣ 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θ)3xdθθx(1θ)3x
      带入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θ)30dθθ0(1θ)30=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θ)31dθθ1(1θ)31=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θ)32dθθ2(1θ)32=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θ)33dθθ3(1θ)33=19290.12346θ3
  2. 有损失函数 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
    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
    2. 画图自己画吧
    3. 有贝叶斯估计为 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]=ecdE[ecθx]cE[θx]+cd1
    4. 有样本的分布函数 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π)2ne21i=1nxi2+nθx2nθ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θ)π(θ)e2n(θx)2
      可以看到后验分布服从正态分布 θ ∣ x ‾ − N ( x ‾ , 1 n ) \theta|\overline{x}-N(\overline{x},\frac1n) θxN(x,n1)
      先求导