贝叶斯课后习题(一)先验分布与后验分布
先验分布与后验分布
-
先验概率可以写为: π ( θ ) { 0.1 , 0.7 0.2 , 0.3 \pi(\theta)\begin{cases}0.1,0.7\\0.2,0.3\end{cases} π(θ){0.1,0.70.2,0.3
x服从二项分布 B ( 8 , θ ) B(8,\theta) B(8,θ)
即 p ( x ∣ θ ) = C 8 x θ x ( 1 − θ ) n − x = { C 8 x 0. 1 x ( 1 − 0.1 ) 8 − x C 8 x 0. 2 x ( 1 − 0.2 ) 8 − x p(x|\theta)=C_8^x\theta^x(1-\theta)^{n-x}=\begin{cases}C_8^x0.1^x(1-0.1)^{8-x}\\C_8^x0.2^x(1-0.2)^{8-x}\end{cases} p(x∣θ)=C8xθx(1−θ)n−x={C8x0.1x(1−0.1)8−xC8x0.2x(1−0.2)8−x
可有联合分布函数为 h ( x , θ ) = p ( x ∣ θ ) π ( θ ) = { C 8 x 0. 1 x ( 1 − 0.1 ) 8 − x 0.7 C 8 x 0. 2 x ( 1 − 0.2 ) 8 − x 0.3 h(x,\theta)=p(x|\theta)\pi(\theta)=\begin{cases}C_8^x0.1^x(1-0.1)^{8-x}0.7\\C_8^x0.2^x(1-0.2)^{8-x}0.3\end{cases} h(x,θ)=p(x∣θ)π(θ)={C8x0.1x(1−0.1)8−x0.7C8x0.2x(1−0.2)8−x0.3
可有x的边缘分布为 m ( x ) = C 8 x 0. 1 x ( 1 − 0.1 ) 8 − x 0.7 + C 8 x 0. 2 x ( 1 − 0.2 ) 8 − x 0.3 m(x)=C_8^x0.1^x(1-0.1)^{8-x}0.7+C_8^x0.2^x(1-0.2)^{8-x}0.3 m(x)=C8x0.1x(1−0.1)8−x0.7+C8x0.2x(1−0.2)8−x0.3
可有后验分布为 π ( θ ∣ x ) = h ( x , θ ) m ( x ) = { C 8 x 0. 1 x ( 1 − 0.1 ) 8 − x 0.7 C 8 x 0. 1 x ( 1 − 0.1 ) 8 − x 0.7 + C 8 x 0. 2 x ( 1 − 0.2 ) 8 − x 0.3 C 8 x 0. 2 x ( 1 − 0.2 ) 8 − x 0.3 C 8 x 0. 1 x ( 1 − 0.1 ) 8 − x 0.7 + C 8 x 0. 2 x ( 1 − 0.2 ) 8 − x 0.3 \pi(\theta|x)=\frac{h(x,\theta)}{m(x)}=\begin{cases}\frac{C_8^x0.1^x(1-0.1)^{8-x}0.7}{C_8^x0.1^x(1-0.1)^{8-x}0.7+C_8^x0.2^x(1-0.2)^{8-x}0.3}\\\frac{C_8^x0.2^x(1-0.2)^{8-x}0.3}{C_8^x0.1^x(1-0.1)^{8-x}0.7+C_8^x0.2^x(1-0.2)^{8-x}0.3}\end{cases} π(θ∣x)=m(x)h(x,θ)=⎩⎨⎧C8x0.1x(1−0.1)8−x0.7+C8x0.2x(1−0.2)8−x0.3C8x0.1x(1−0.1)8−x0.7C8x0.1x(1−0.1)8−x0.7+C8x0.2x(1−0.2)8−x0.3C8x0.2x(1−0.2)8−x0.3
带入x=3可求得 π ( θ ∣ x ) = { 0.1 , 0.5418274451 0.2 , 0.4581725549 \pi(\theta|x)=\begin{cases}0.1,0.5418274451\\0.2,0.4581725549\end{cases} π(θ∣x)={0.1,0.54182744510.2,0.4581725549
-
先验分布概率可以有: π ( θ ) = { 1.0 , 0.4 1.5 , 0.6 \pi(\theta)=\begin{cases}1.0,0.4\\1.5,0.6\end{cases} π(θ)={1.0,0.41.5,0.6
x服从泊松分布 p ( x ∣ θ ) = θ x e − θ Γ ( x + 1 ) = { e − 1 Γ ( x + 1 ) 1. 5 x e − 1.5 Γ ( x + 1 ) p(x|\theta)=\frac{\theta^xe^{-\theta}}{\Gamma(x+1)}=\begin{cases}\frac{e^{-1}}{\Gamma(x+1)}\\\frac{1.5^{x}e^{-1.5}}{\Gamma(x+1)}\end{cases} p(x∣θ)=Γ(x+1)θxe−θ={Γ(x+1)e−1Γ(x+1)1.5xe−1.5
有联合概率函数 h ( x , θ ) = p ( x ∣ θ ) π ( θ ) = { e − 1 Γ ( x + 1 ) 0.4 1. 5 x e − 1.5 Γ ( x + 1 ) 0.6 h(x,\theta)=p(x|\theta)\pi(\theta)=\begin{cases}\frac{e^{-1}}{\Gamma(x+1)}0.4\\\frac{1.5^{x}e^{-1.5}}{\Gamma(x+1)}0.6\end{cases} h(x,θ)=p(x∣θ)π(θ)={Γ(x+1)e−10.4Γ(x+1)1.5xe−1.50.6
有x的边缘分布 m ( x ) = e − 1 Γ ( x + 1 ) 0.4 + 1. 5 x e − 1.5 Γ ( x + 1 ) 0.6 m(x)=\frac{e^{-1}}{\Gamma(x+1)}0.4+\frac{1.5^{x}e^{-1.5}}{\Gamma(x+1)}0.6 m(x)=Γ(x+1)e−10.4+Γ(x+1)1.5xe−1.50.6
可有后验分布 π ( θ ∣ x ) = h ( x , θ ) m ( x ) = { e − 1 Γ ( x + 1 ) 0.4 e − 1 Γ ( x + 1 ) 0.4 + 1. 5 x e − 1.5 Γ ( x + 1 ) 0.6 1. 5 x e − 1.5 Γ ( x + 1 ) 0.6 e − 1 Γ ( x + 1 ) 0.4 + 1. 5 x e − 1.5 Γ ( x + 1 ) 0.6 \pi(\theta|x)=\frac{h(x,\theta)}{m(x)}=\begin{cases}\frac{\frac{e^{-1}}{\Gamma(x+1)}0.4}{\frac{e^{-1}}{\Gamma(x+1)}0.4+\frac{1.5^{x}e^{-1.5}}{\Gamma(x+1)}0.6}\\\frac{\frac{1.5^{x}e^{-1.5}}{\Gamma(x+1)}0.6}{\frac{e^{-1}}{\Gamma(x+1)}0.4+\frac{1.5^{x}e^{-1.5}}{\Gamma(x+1)}0.6}\end{cases} π(θ∣x)=m(x)h(x,θ)=⎩⎪⎪⎨⎪⎪⎧Γ(x+1)e−10.4+Γ(x+1)1.5xe−1.50.6Γ(x+1)e−10.4Γ(x+1)e−10.4+Γ(x+1)1.5xe−1.50.6Γ(x+1)1.5xe−1.50.6
带入x=3,可有 π ( θ ∣ x ) = { 0.2456663555 0.7543336445 \pi(\theta|x)=\begin{cases}0.2456663555\\0.7543336445\end{cases} π(θ∣x)={0.24566635550.7543336445
-
先求先验分布
-
π ( θ ) = { 1 0 < θ < 1 0 o t h e r \pi(\theta)=\begin{cases}1&0<\theta<1\\0&other\end{cases} π(θ)={100<θ<1other
x是满足二项分布的,即 p ( x ∣ θ ) = C 8 x θ x ( 1 − θ ) 8 − x p(x|\theta)=C_8^x\theta^x(1-\theta)^{8-x} p(x∣θ)=C8xθx(1−θ)8−x
可有联合密度函数 h ( x , θ ) = p ( x ∣ θ ) π ( θ ) = C 8 x θ x ( 1 − θ ) n − x , 0 < θ < 1 h(x,\theta)=p(x|\theta)\pi(\theta)=C_8^x\theta^x(1-\theta)^{n-x},0<\theta<1 h(x,θ)=p(x∣θ)π(θ)=C8xθx(1−θ)n−x,0<θ<1
可有x的边缘分布 m ( x ) = ∫ 0 1 h ( x , θ ) d θ = C 8 x ∫ 0 1 θ x ( 1 − θ ) n − x d θ m(x)=\int_0^1h(x,\theta)d\theta=C_8^x\int_0^1\theta^x(1-\theta)^{n-x}d\theta m(x)=∫01h(x,θ)dθ=C8x∫01θx(1−θ)n−xdθ
可有 后验分布 π ( θ ∣ x ) = h ( x ∣ θ ) m ( x ) = θ x ( 1 − θ ) n − x ∫ 0 1 θ x ( 1 − θ ) n − x d θ = θ x ( 1 − θ ) n − x Γ ( x + 1 ) Γ ( 8 − x + 1 ) Γ ( x + 1 + 8 − x + 1 ) = Γ ( 10 ) θ x ( 1 − θ ) 8 − x Γ ( x + 1 ) Γ ( 9 − x ) \pi(\theta|x)=\frac{h(x|\theta)}{m(x)}=\frac{\theta^x(1-\theta)^{n-x}}{\int_0^1\theta^x(1-\theta)^{n-x}d\theta}=\frac{\theta^x(1-\theta)^{n-x}}{\frac{\Gamma(x+1)\Gamma(8-x+1)}{\Gamma(x+1+8-x+1)}}=\frac{\Gamma(10)\theta^x(1-\theta)^{8-x}}{\Gamma(x+1)\Gamma(9-x)} π(θ∣x)=m(x)h(x∣θ)=∫01θx(1−θ)n−xdθθx(1−θ)n−x=Γ(x+1+8−x+1)Γ(x+1)Γ(8−x+1)θx(1−θ)n−x=Γ(x+1)Γ(9−x)Γ(10)θx(1−θ)8−x
带入x=3可有 π ( θ ∣ x = 3 ) = θ 3 ( 1 − θ ) 8 − 3 ∫ 0 1 θ 3 ( 1 − θ ) 8 − 3 d θ = Γ ( 10 ) θ 3 ( 1 − θ ) 8 − 3 Γ ( 3 + 1 ) Γ ( 9 − 3 ) = 504 θ 3 ( 1 − θ ) 5 \pi(\theta|x=3)=\frac{\theta^3(1-\theta)^{8-3}}{\int_0^1\theta^3(1-\theta)^{8-3}d\theta}=\frac{\Gamma(10)\theta^3(1-\theta)^{8-3}}{\Gamma(3+1)\Gamma(9-3)}=504\theta^3(1-\theta)^5 π(θ∣x=3)=∫01θ3(1−θ)8−3dθθ3(1−θ)8−3=Γ(3+1)Γ(9−3)Γ(10)θ3(1−θ)8−3=504θ3(1−θ)5
-
π ( θ ) = { 2 ( 1 − θ ) 0 < θ < 1 0 o t h e r \pi(\theta)=\begin{cases}2(1-\theta)&0<\theta<1\\0&other\end{cases} π(θ)={2(1−θ)00<θ<1other
x是满足二项分布的,即 p ( x ∣ θ ) = C 8 x θ x ( 1 − θ ) 8 − x p(x|\theta)=C_8^x\theta^x(1-\theta)^{8-x} p(x∣θ)=C8xθx(1−θ)8−x
可有联合密度函数 h ( x , θ ) = p ( x ∣ θ ) π ( θ ) = C 8 x θ x ( 1 − θ ) n − x 2 ( 1 − θ ) , 0 < θ < 1 h(x,\theta)=p(x|\theta)\pi(\theta)=C_8^x\theta^x(1-\theta)^{n-x}2(1-\theta),0<\theta<1 h(x,θ)=p(x∣θ)π(θ)=C8xθx(1−θ)n−x2(1−θ),0<θ<1
可有x的边缘分布 m ( x ) = ∫ 0 1 h ( x , θ ) d θ = 2 C 8 x ∫ 0 1 θ x ( 1 − θ ) n − x + 1 d θ m(x)=\int_0^1h(x,\theta)d\theta=2C_8^x\int_0^1\theta^x(1-\theta)^{n-x+1}d\theta m(x)=∫01h(x,θ)dθ=2C8x∫01θx(1−θ)n−x+1dθ
可有后验分布 π ( θ ∣ x ) = h ( x ∣ θ ) m ( x ) = θ x ( 1 − θ ) n − x + 1 ∫ 0 1 θ x ( 1 − θ ) n − x + 1 d θ = θ x ( 1 − θ ) n − x + 1 Γ ( x + 1 ) Γ ( 8 − x + 1 + 1 ) Γ ( x + 1 + 8 − x + 1 + 1 ) = Γ ( 11 ) θ x ( 1 − θ ) 9 − x Γ ( x + 1 ) Γ ( 10 − x ) \pi(\theta|x)=\frac{h(x|\theta)}{m(x)}=\frac{\theta^x(1-\theta)^{n-x+1}}{\int_0^1\theta^x(1-\theta)^{n-x+1}d\theta}=\frac{\theta^x(1-\theta)^{n-x+1}}{\frac{\Gamma(x+1)\Gamma(8-x+1+1)}{\Gamma(x+1+8-x+1+1)}}=\frac{\Gamma(11)\theta^x(1-\theta)^{9-x}}{\Gamma(x+1)\Gamma(10-x)} π(θ∣x)=m(x)h(x∣θ)=∫01θx(1−θ)n−x+1dθθx(1−θ)n−x+1=Γ(x+1+8−x+1+1)Γ(x+1)Γ(8−x+1+1)θx(1−θ)n−x+1=Γ(x+1)Γ(10−x)Γ(11)θx(1−θ)9−x
带入x=3可有 π ( θ ∣ x = 3 ) = θ 3 ( 1 − θ ) n − 3 + 1 Γ ( 3 + 1 ) Γ ( 8 − 3 + 1 + 1 ) Γ ( 3 + 1 + 8 − 3 + 1 + 1 ) = Γ ( 11 ) θ 3 ( 1 − θ ) 9 − 3 Γ ( 3 + 1 ) Γ ( 10 − 3 ) = 840 θ 3 ( 1 − θ ) 6 \pi(\theta|x=3)=\frac{\theta^3(1-\theta)^{n-3+1}}{\frac{\Gamma(3+1)\Gamma(8-3+1+1)}{\Gamma(3+1+8-3+1+1)}}=\frac{\Gamma(11)\theta^3(1-\theta)^{9-3}}{\Gamma(3+1)\Gamma(10-3)}=840\theta^3(1-\theta)^6 π(θ∣x=3)=Γ(3+1+8−3+1+1)Γ(3+1)Γ(8−3+1+1)θ3(1−θ)n−3+1=Γ(3+1)Γ(10−3)Γ(11)θ3(1−θ)9−3=840θ3(1−θ)6
-
-
由 π ( θ ∣ x ) ∝ p ( θ ∣ x ) π ( θ ) \pi(\theta|x)\varpropto p(\theta|x)\pi(\theta) π(θ∣x)∝p(θ∣x)π(θ)显然易得
-
首先求先验分布 π ( θ ) = { 1 10 ( 10 , 20 ) 0 o t h e r \pi(\theta)=\begin{cases}\frac1{10}&(10,20)\\0&other\end{cases} π(θ)={1010(10,20)other
-
x满足 p ( x ∣ θ ) = { 1 ( θ − 1 2 , θ + 1 2 ) 0 o t h e r p(x|\theta)=\begin{cases}1&(\theta-\frac12,\theta+\frac12)\\0&other\end{cases} p(x∣θ)={10(θ−21,θ+21)other
可有联合概率函数 h ( x , θ ) = p ( x ∣ θ ) π ( θ ) = 1 10 , 11.5 < θ < 12.5 h(x,\theta)=p(x|\theta)\pi(\theta)=\frac1{10},11.5<\theta<12.5 h(x,θ)=p(x∣θ)π(θ)=101,11.5<θ<12.5
可有x的边缘分布 m ( x ) = ∫ 11.5 12.5 1 10 d θ = 0.1 m(x)=\int_{11.5}^{12.5}\frac1{10}d\theta=0.1 m(x)=∫11.512.5101dθ=0.1
可有后验分布 π ( θ ∣ x ) = 1 , 11.5 < θ < 12.5 \pi(\theta|x)=1,11.5<\theta<12.5 π(θ∣x)=1,11.5<θ<12.5
-
x满足 p ( x ∣ θ ) = { 1 ( θ − 1 2 , θ + 1 2 ) 0 o t h e r p(x|\theta)=\begin{cases}1&(\theta-\frac12,\theta+\frac12)\\0&other\end{cases} p(x∣θ)={10(θ−21,θ+21)other
可有联合概率函数 h ( x , θ ) = p ( x ∣ θ ) π ( θ ) = 1 10 , 11.5 < θ < 11.6 h(x,\theta)=p(x|\theta)\pi(\theta)=\frac1{10},11.5<\theta<11.6 h(x,θ)=p(x∣θ)π(θ)=101,11.5<θ<11.6。这里是 θ \theta θ的范围取交集,即下限的上限,上限的下限
可有x的边缘分布 m ( x ) = ∫ 11.5 11.6 1 10 d θ = 0.01 m(x)=\int_{11.5}^{11.6}\frac1{10}d\theta=0.01 m(x)=∫11.511.6101dθ=0.01
可有后验分布 π ( θ ∣ x ) = 10 , 11.5 < θ < 11.6 \pi(\theta|x)=10,11.5<\theta<11.6 π(θ∣x)=10,11.5<θ<11.6
-
-
先验分布 π ( λ ) ∝ λ α − 1 e − β λ \pi(\lambda)\varpropto\lambda^{\alpha-1}e^{-\beta\lambda} π(λ)∝λα−1e−βλ
x的概率函数 p ( x ∣ λ ) ∝ λ x e − λ p(x|\lambda)\varpropto\lambda^xe^{-\lambda} p(x∣λ)∝λxe−λ
λ \lambda λ的后验分布 π ( λ ∣ x ) ∝ p ( x ∣ λ ) π ( λ ) ∝ λ x e − λ λ α − 1 e − β λ ∝ λ x + α − 1 e − ( β + 1 ) λ \pi(\lambda|x)\varpropto p(x|\lambda)\pi(\lambda)\varpropto\lambda^xe^{-\lambda}\lambda^{\alpha-1}e^{-\beta\lambda}\varpropto\lambda^{x+\alpha-1}e^{-(\beta+1)\lambda} π(λ∣x)∝p(x∣λ)π(λ)∝λxe−λλα−1e−βλ∝λx+α−1e−(β+1)λ
可以看到,这是一个伽马分布 G a ( x + α , β + 1 ) Ga(x+\alpha,\beta+1) Ga(x+α,β+1)
-
先求先验
-
π ( θ ) = { 1 ( 0 , 1 ) 0 o t h e r \pi(\theta)=\begin{cases}1&(0,1)\\0&other\end{cases} π(θ)={10(0,1)other
再求x的概率函数 p ( x ∣ θ ) = 2 x θ 2 p(x|\theta)=\frac{2x}{\theta^2} p(x∣θ)=θ22x
可有联合概率函数 h ( x , θ ) = p ( x ∣ θ ) π ( θ ) = 2 x θ 2 , x < θ < 1 h(x,\theta)=p(x|\theta)\pi(\theta)=\frac{2x}{\theta^2},x<\theta<1 h(x,θ)=p(x∣θ)π(θ)=θ22x,x<θ<1
可有x的边缘分布 m ( x ) = ∫ x 1 h ( x , θ ) d θ = ∫ x 1 2 θ 2 d θ = 2 ( 1 − x ) m(x)=\int_x^1h(x,\theta)d\theta=\int_x^1\frac{2}{\theta^2}d\theta=2(1-x) m(x)=∫x1h(x,θ)dθ=∫x1θ22dθ=2(1−x)
可有后验分布 π ( θ ∣ x ) = h ( x , θ ) m ( x ) = x 1 − x θ − 2 , x < θ < 1 \pi(\theta|x)=\frac{h(x,\theta)}{m(x)}=\frac{x}{1-x}\theta^{-2},x<\theta<1 π(θ∣x)=m(x)h(x,θ)=1−xxθ−2,x<θ<1
-
π ( θ ) = { 3 θ 2 0 < θ < 1 0 o t h e r \pi(\theta)=\begin{cases}3\theta^2&0<\theta<1\\0&other\end{cases} π(θ)={3θ200<θ<1other
再求x的概率函数 p ( x ∣ θ ) = 2 x θ 2 p(x|\theta)=\frac{2x}{\theta^2} p(x∣θ)=θ22x
可有联合概率函数 h ( x , θ ) = p ( x ∣ θ ) π ( θ ) = 2 x θ 2 3 θ 2 = 6 x , x < θ < 1 h(x,\theta)=p(x|\theta)\pi(\theta)=\frac{2x}{\theta^2}3\theta^2=6x,x<\theta<1 h(x,θ)=p(x∣θ)π(θ)=θ22x3θ2=6x,x<θ<1
可有x的边缘分布 m ( x ) = ∫ x 1 6 x d θ = 6 x ( 1 − x ) m(x)=\int_x^16xd\theta=6x(1-x) m(x)=∫x16xdθ=6x(1−x)
可有后验分布 π ( θ ∣ x ) = h ( x , θ ) m ( x ) = 6 x 6 x ( 1 − x ) = 1 1 − x , x < θ < 1 \pi(\theta|x)=\frac{h(x,\theta)}{m(x)}=\frac{6x}{6x(1-x)}=\frac1{1-x},x<\theta<1 π(θ∣x)=m(x)h(x,θ)=6x(1−x)6x=1−x1,x<θ<1
-
-
先求先验分布 π ( θ ) = Γ ( 202 ) Γ ( 2 ) Γ ( 200 ) θ 1 ( 1 − θ ) 199 \pi(\theta)=\frac{\Gamma(202)}{\Gamma(2)\Gamma(200)}{\theta}^{1}(1-\theta)^{199} π(θ)=Γ(2)Γ(200)Γ(202)θ1(1−θ)199
再求x的概率函数,为二项分布 B ( 100 , θ ) , p ( x ∣ θ ) = C 100 x θ x ( 1 − θ ) 100 − x B(100,\theta),p(x|\theta)=C_{100}^x\theta^x(1-\theta)^{100-x} B(100,θ),p(x∣θ)=C100xθx(1−θ)100−x
可有联合概率函数 h ( x , θ ) = p ( x ∣ θ ) π ( θ ) = C 100 x θ x ( 1 − θ ) 100 − x Γ ( 202 ) Γ ( 2 ) Γ ( 200 ) θ 1 ( 1 − θ ) 199 , 0 < θ < 1 h(x,\theta)=p(x|\theta)\pi(\theta)=C_{100}^x\theta^x(1-\theta)^{100-x}\frac{\Gamma(202)}{\Gamma(2)\Gamma(200)}{\theta}^{1}(1-\theta)^{199},0<\theta<1 h(x,θ)=p(x∣θ)π(θ)=C100xθx(1−θ)100−xΓ(2)Γ(200)Γ(202)θ1(1−θ)199,0<θ<1
可有x的边缘分布 m ( x ) = ∫ 0 1 h ( x , θ ) d θ = ∫ 0 1 C 100 x θ x ( 1 − θ ) 100 − x Γ ( 202 ) Γ ( 2 ) Γ ( 200 ) θ 1 ( 1 − θ ) 199 = C 100 x Γ ( 202 ) Γ ( 2 ) Γ ( 200 ) ∫ 0 1 θ x ( 1 − θ ) 100 − x θ 1 ( 1 − θ ) 199 d θ m(x)=\int_0^1h(x,\theta)d\theta=\int_0^1C_{100}^x\theta^x(1-\theta)^{100-x}\frac{\Gamma(202)}{\Gamma(2)\Gamma(200)}{\theta}^{1}(1-\theta)^{199}\\=C_{100}^x\frac{\Gamma(202)}{\Gamma(2)\Gamma(200)}\int_0^1\theta^x(1-\theta)^{100-x}{\theta}^{1}(1-\theta)^{199}d\theta m(x)=∫01h(x,θ)dθ=∫01C100xθx(1−θ)100−xΓ(2)Γ(200)Γ(202)θ1(1−θ)199=C100xΓ(2)Γ(200)Γ(202)∫01θx(1−θ)100−xθ1(1−θ)199dθ
可有后验分布 π ( θ ∣ x ) = h ( x , θ ) m ( x ) = C 100 x Γ ( 202 ) Γ ( 2 ) Γ ( 200 ) θ x ( 1 − θ ) 100 − x θ 1 ( 1 − θ ) 199 C 100 x Γ ( 202 ) Γ ( 2 ) Γ ( 200 ) ∫ 0 1 θ x ( 1 − θ ) 100 − x θ 1 ( 1 − θ ) 199 d θ = θ x ( 1 − θ ) 100 − x θ 1 ( 1 − θ ) 199 ∫ 0 1 θ x ( 1 − θ ) 100 − x θ 1 ( 1 − θ ) 199 d θ = θ x ( 1 − θ ) 100 − x θ 1 ( 1 − θ ) 199 Γ ( x + 1 + 1 ) Γ ( 299 − x + 1 ) Γ ( 302 ) \pi(\theta|x)=\frac{h(x,\theta)}{m(x)}=\frac{C_{100}^x\frac{\Gamma(202)}{\Gamma(2)\Gamma(200)}\theta^x(1-\theta)^{100-x}{\theta}^{1}(1-\theta)^{199}}{C_{100}^x\frac{\Gamma(202)}{\Gamma(2)\Gamma(200)}\int_0^1\theta^x(1-\theta)^{100-x}{\theta}^{1}(1-\theta)^{199}d\theta}\\=\frac{\theta^x(1-\theta)^{100-x}{\theta}^{1}(1-\theta)^{199}}{\int_0^1\theta^x(1-\theta)^{100-x}{\theta}^{1}(1-\theta)^{199}d\theta}=\frac{\theta^x(1-\theta)^{100-x}{\theta}^{1}(1-\theta)^{199}}{\frac{\Gamma(x+1+1)\Gamma(299-x+1)}{\Gamma(302)}} π(θ∣x)=m(x)h(x,θ)=C100xΓ(2)Γ(200)Γ(202)∫01θx(1−θ)100−xθ1(1−θ)199dθC100xΓ(2)Γ(200)Γ(202)θx(1−θ)100−xθ1(1−θ)199=∫01θx(1−θ)100−xθ1(1−θ)199dθθx(1−θ)100−xθ1(1−θ)199=Γ(302)Γ(x+1+1)Γ(299−x+1)θx(1−θ)100−xθ1(1−θ)199
带入x=3有后验分布 π ( θ ∣ x = 3 ) = θ 4 ( 1 − θ ) 296 4 ! 296 ! 302 ! \pi(\theta|x=3)=\frac{\theta^4(1-\theta)^{296}}{\frac{4!296!}{302!}} π(θ∣x=3)=302!4!296!θ4(1−θ)296即 B e ( 5 , 297 ) Be(5,297) Be(5,297)
-
先求先验分布 N ( 172.72 , 2.54 ) N(172.72,2.54) N(172.72,2.54)
x的分布为 N ( θ , 5 2 ) N(\theta,5^2) N(θ,52)
-
有 x ‾ − N ( θ , 5 2 10 ) \overline{x}-N(\theta,\frac{5^2}{10}) x−N(θ,1052)
有 p ( x ‾ ∣ θ ) ∝ ( 1 2 π 25 10 ) e x p { ( x ‾ − θ ) 2 5 } p(\overline{x}|\theta)\varpropto(\frac1{\sqrt{2\pi\frac{25}{10}}})exp\{\frac{(\overline{x}-\theta)^2}{5}\} p(x∣θ)∝(2π10251)exp{5(x−θ)2}
可有 π ( θ ) ∝ ( 1 2 π 2.54 ) e x p { ( θ − 172.72 ) 2 2 ∗ 2.54 } \pi(\theta)\varpropto(\frac1{\sqrt{2\pi2.54}})exp\{\frac{(\theta-172.72)^2}{2*2.54}\} π(θ)∝(2π2.541)exp{2∗2.54(θ−172.72)2}
可有 π ( θ ∣ x ) ∝ p ( x ∣ θ ) π ( θ ) ∝ ( 1 2 π 2.5 ∗ 2.54 ) e x p { ( 176.53 − θ ) 2 5 + ( θ − 172.72 ) 2 2 ∗ 2.54 } \pi(\theta|x)\varpropto p(x|\theta)\pi(\theta)\\\varpropto(\frac1{\sqrt{2\pi2.5*2.54}})exp\{\frac{(176.53-\theta)^2}{5}+\frac{(\theta-172.72)^2}{2*2.54}\} π(θ∣x)∝p(x∣θ)π(θ)∝(2π2.5∗2.541)exp{5(176.53−θ)2+2∗2.54(θ−172.72)2}
可有 θ ∣ x ‾ − N ( 174.64 , 1.26 ) \theta|\overline{x}-N(174.64,1.26) θ∣x−N(174.64,1.26)
-
想要在区间上的概率最大,就需要让这个区间的重点与分布的均值重合,所以区间是 [ 173.39 , 175.89 ] [173.39,175.89] [173.39,175.89]
-
求积分即可, p ( θ ∈ Θ ) = ∫ 173.39 175.89 π ( θ ∣ x ) d θ p(\theta\in\Theta)=\int_{173.39}^{175.89}\pi(\theta|x)d\theta p(θ∈Θ)=∫173.39175.89π(θ∣x)dθ
-
-
首先,有 x ‾ − N ( θ , 1 25 ) \overline{x}-N(\theta,\frac1{25}) x−N(θ,251)
后有 π ( θ ) − N ( μ , σ 2 ) \pi(\theta)-N(\mu,\sigma^2) π(θ)−N(μ,σ2)
可有 π ( θ ) ∝ ( 1 σ ) e x p { ( θ − μ ) 2 2 σ 2 } \pi(\theta)\varpropto(\frac1{\sigma})exp\{\frac{(\theta-\mu)^2}{2\sigma^2}\} π(θ)∝(σ1)exp{2σ2(θ−μ)2}
可有 p ( x ‾ ∣ θ ) = e x p { ( x ‾ − θ ) 2 2 / 25 } p(\overline{x}|\theta)=exp\{\frac{(\overline{x}-\theta)^2}{2/25}\} p(x∣θ)=exp{2/25(x−θ)2}
即 π ( θ ∣ x ‾ ) ∝ e x p { ( θ − μ ) 2 2 σ 2 + 25 ( x ‾ − θ ) 2 2 } ∝ e x p { ( θ − μ ) 2 + 25 σ 2 ( x ‾ − θ ) 2 2 σ 2 } \pi(\theta|\overline x)\varpropto exp\{\frac{(\theta-\mu)^2}{2\sigma^2}+\frac{25(\overline{x}-\theta)^2}{2}\}\\\varpropto exp\{\frac{(\theta-\mu)^2+25\sigma^2(\overline x-\theta)^2}{2\sigma^2}\} π(θ∣x)∝exp{2σ2(θ−μ)2+225(x−θ)2}∝exp{2σ2(θ−μ)2+25σ2(x−θ)2}
转为正态分布的形式,可有 π ( θ ∣ x ‾ ) ∝ e x p { ( 25 σ 2 + 1 ) θ 2 − ( 50 σ 2 x ‾ + 2 μ ) θ + μ 2 + 25 σ 2 x ‾ 2 2 σ 2 } \pi(\theta|\overline x)\varpropto exp\{\frac{(25\sigma^2+1)\theta^2-(50\sigma^2\overline{x}+2\mu)\theta+\mu^2+25\sigma^2\overline x^2}{2\sigma^2}\} π(θ∣x)∝exp{2σ2(25σ2+1)θ2−(50σ2x+2μ)θ+μ2+25σ2x2}
可有,后验分布的方差为 σ 2 25 σ 2 + 1 \frac{\sigma^2}{25\sigma^2+1} 25σ2+1σ2,可化简为 1 25 + 1 / σ 2 \frac1{25+1/\sigma^2} 25+1/σ21,其中 σ 2 \sigma^2 σ2是先验分布的方差
可以看到,后验方差存在上界 1 25 \frac1{25} 251,故后验标准差必然存在上界 1 5 \frac15 51
-
先求先验分布 π ( θ ) = { 192 / θ 4 θ ≥ 4 0 θ < 0 \pi(\theta)=\begin{cases}192/\theta^4&\theta\ge4\\0&\theta<0\end{cases} π(θ)={192/θ40θ≥4θ<0
根据样本可有 p ( x ∣ θ ) = 1 θ 3 , 0 < x < θ p(x|\theta)=\frac1{\theta^3},0<x<\theta p(x∣θ)=θ31,0<x<θ
可有联合概率函数 h ( x , θ ) = 192 / θ 7 , 0 < x < θ , θ > 8 h(x,\theta)=192/\theta^7,0<x<\theta,\theta>8 h(x,θ)=192/θ7,0<x<θ,θ>8
可有x的边缘分布 m ( x ) = ∫ 8 ∞ 192 / θ 7 d θ m(x)=\int_8^{\infty}192/\theta^7d\theta m(x)=∫8∞192/θ7dθ
可有后验分布 π ( θ ∣ x ) = h ( x , θ ) m ( x ) = 8192 θ 7 \pi(\theta|x)=\frac{h(x,\theta)}{m(x)}=\frac{8192}{\theta^7} π(θ∣x)=m(x)h(x,θ)=θ78192
-
首先有先验分布 π ( θ ) ∝ α θ 0 α θ α − 1 , θ > θ 0 \pi(\theta)\varpropto \frac{\alpha\theta_0^{\alpha}}{\theta^{\alpha-1}},\theta>\theta_0 π(θ)∝θα−1αθ0α,θ>θ0
后有x的概率函数 p ( x ∣ θ ) ∝ 1 θ p(x|\theta)\varpropto \frac1{\theta} p(x∣θ)∝θ1
π ( θ ∣ x ) ∝ p ( x ∣ θ ) π ( θ ) ∝ α θ 0 α θ α − 1 1 θ , θ > θ 0 ∝ α θ 0 α θ α \pi(\theta|x)\varpropto p(x|\theta)\pi(\theta)\varpropto \frac{\alpha\theta_0^{\alpha}}{\theta^{\alpha-1}}\frac1{\theta},\theta>\theta_0\varpropto \frac{\alpha\theta_0^{\alpha}}{\theta^{\alpha}} π(θ∣x)∝p(x∣θ)π(θ)∝θα−1αθ0αθ1,θ>θ0∝θααθ0α
可以看到,后验分布仍然是pareto分布
-
根据均值和方差可以求出, α α + β = 1 / 3 , α β ( α + β ) 2 ( α + β + 1 ) = 1 / 45 \frac{\alpha}{\alpha+\beta}=1/3,\frac{\alpha\beta}{(\alpha+\beta)^2(\alpha+\beta+1)}=1/45 α+βα=1/3,(α+β)2(α+β+1)αβ=1/45
可有 α = 3 , β = 6 \alpha=3,\beta=6 α=3,β=6
此时先验分布为 B e ( 3 , 6 ) Be(3,6) Be(3,6)
-
有样本的分布函数为 p ( x ∣ λ ) = λ n e − λ ∑ i = 1 n x i p(x|\lambda)=\lambda^ne^{-\lambda\sum_{i=1}^nx_i} p(x∣λ)=λne−λ∑i=1nxi
-
先验分布有 π ( λ ) ∝ λ α − 1 e − β λ \pi(\lambda)\varpropto \lambda^{\alpha-1}e^{-\beta\lambda} π(λ)∝λα−1e−βλ
可有后验分布 π ( λ ∣ x ) ∝ p ( x ∣ λ ) π ( λ ) ∝ λ n e − λ ∑ i = 1 n x i λ α − 1 e − β λ ∝ λ n + α − 1 e − λ ( ∑ i = 1 n x i + β ) \pi(\lambda|x)\varpropto p(x|\lambda)\pi(\lambda)\varpropto\lambda^ne^{-\lambda\sum_{i=1}^nx_i}\lambda^{\alpha-1}e^{-\beta\lambda}\\\varpropto\lambda^{n+\alpha-1}e^{-\lambda(\sum_{i=1}^nx_i+\beta)} π(λ∣x)∝p(x∣λ)π(λ)∝λne−λ∑i=1nxiλα−1e−βλ∝λn+α−1e−λ(∑i=1nxi+β)
可以看到,仍然是伽马分布的形式
-
根据伽马分布可有 α β = 0.0002 , α β 2 = 0.0001 \frac{\alpha}{\beta}=0.0002,\frac{\alpha}{\beta^2}=0.0001 βα=0.0002,β2α=0.0001
可解得 α = 0.0004 , β = 2 \alpha=0.0004,\beta=2 α=0.0004,β=2
-
-
有 x − N ( θ 1 , 1 2 θ 2 ) x-N(\theta_1,\frac1{2\theta_2}) x−N(θ1,2θ21)
p ( x ∣ θ ) = ( 1 2 π ∗ 1 2 θ 2 ) e x p { − ( x − θ 1 ) 2 1 θ 2 } p(x|\theta)=(\frac1{\sqrt{2\pi*\frac1{2\theta_2}}})exp\{-\frac{(x-\theta_1)^2}{\frac1{\theta2}}\} p(x∣θ)=(2π∗2θ211)exp{−θ21(x−θ1)2}
可有 p ( x ‾ ∣ θ 1 , θ 2 ) ∝ θ 2 n 2 e x p { − θ 2 ∑ i = 1 n ( x i − θ 1 ) 2 } p(\overline{x}|\theta_1,\theta_2)\varpropto \theta_2^{\frac n2}exp\{-\theta_2\sum_{i=1}^n(x_i-\theta_1)^2\} p(x∣θ1,θ2)∝θ22nexp{−θ2∑i=1n(xi−θ1)2}
有 θ 1 ∣ θ 2 − N ( 0 , 1 2 θ 2 ) \theta_1|\theta_2-N(0,\frac1{2\theta_2}) θ1∣θ2−N(0,2θ21)
可有 π ( θ 1 , θ 2 ) = π ( θ 1 ∣ θ 2 ) π ( θ 2 ) ∝ ( 1 2 π 1 2 θ 2 ) e x p { − ( θ 1 ) 2 1 θ 2 } λ α Γ ( α ) θ 2 α − 1 e − λ θ 2 \pi(\theta_1,\theta_2)=\pi(\theta_1|\theta_2)\pi(\theta_2)\varpropto (\frac1{\sqrt{2\pi\frac1{2\theta_2}}})exp\{-\frac{(\theta_1)^2}{\frac1{\theta_2}}\}\frac{\lambda^{\alpha}}{\Gamma(\alpha)}\theta_2^{\alpha-1}e^{-\lambda\theta_2} π(θ1,θ2)=π(θ1∣θ2)π(θ2)∝(2π2θ211)exp{−θ21(θ1)2}Γ(α)λαθ2α−1e−λθ2
即 π ( θ 1 , θ 2 ) ∝ λ α Γ ( α ) θ 2 1 2 + α − 1 e x p { − θ 2 ( θ 1 2 + λ ) } \pi(\theta_1,\theta_2)\varpropto \frac{\lambda^{\alpha}}{\Gamma(\alpha)}\theta_2^{\frac12+\alpha-1}exp\{-\theta_2(\theta_1^2+\lambda)\} π(θ1,θ2)∝Γ(α)λαθ221+α−1exp{−θ2(θ12+λ)}
可有 π ( θ 1 , θ 2 ∣ x ) ∝ p ( x ‾ ∣ θ 1 , θ 2 ) π ( θ 1 , θ 2 ) ∝ θ 2 n 2 e x p { − θ 2 ∑ i = 1 n ( x i − θ 1 ) 2 } λ α Γ ( α ) θ 2 1 2 + α − 1 e x p { − θ 2 ( θ 1 2 + λ ) } ∝ θ 2 n + 1 2 + α − 1 e x p { − θ 2 ( ∑ i = 1 n x i 2 − 2 θ 1 ∑ i = 1 n x i + ( n + 1 ) θ 1 2 + λ ) } \pi(\theta_1,\theta_2|x)\varpropto p(\overline{x}|\theta_1,\theta_2)\pi(\theta_1,\theta_2)\\ \varpropto \theta_2^{\frac n2}exp\{-\theta_2\sum_{i=1}^n(x_i-\theta_1)^2\}\frac{\lambda^{\alpha}}{\Gamma(\alpha)}\theta_2^{\frac12+\alpha-1}exp\{-\theta_2(\theta_1^2+\lambda)\}\\\varpropto \theta_2^{\frac{n+1}2+\alpha-1}exp\{-\theta_2(\sum_{i=1}^nx_i^2-2\theta_1\sum_{i=1}^nx_i+(n+1)\theta_1^2+\lambda)\} π(θ1,θ2∣x)∝p(x∣θ1,θ2)π(θ1,θ2)∝θ22nexp{−θ2∑i=1n(xi−θ1)2}Γ(α)λαθ221+α−1exp{−θ2(θ12+λ)}∝θ22n+1+α−1exp{−θ2(∑i=1nxi2−2θ1∑i=1nxi+(n+1)θ12+λ)} -
比较麻烦,用核比较好
有 p ( X ∣ θ ) = ∏ i = 1 n p ( x i ∣ θ ) = c n ( θ ) e x p { ϕ ( θ ) ∑ i = 1 n T ( x i ) } ∏ i = 1 n h ( x i ) p(X|\theta)=\prod_{i=1}^np(x_i|\theta)=c^n(\theta)exp\{\phi(\theta)\sum_{i=1}^nT(x_i)\}\prod_{i=1}^nh(x_i) p(X∣θ)=∏i=1np(xi∣θ)=cn(θ)exp{ϕ(θ)∑i=1nT(xi)}∏i=1nh(xi)
可有 π ( θ ∣ X ) ∝ p ( X ∣ θ ) π ( θ ) ∝ c n ( θ ) e x p { ϕ ( θ ) ∑ i = 1 n T ( x i ) } ∏ i = 1 n h ( x i ) c η ( θ ) e x p { ϕ ( θ ) ν } ∝ c n + η ( θ ) e x p { ( ∑ i = 1 n T ( x i ) ∏ i = 1 n h ( x i ) + ν ) ϕ ( θ ) } \pi(\theta|X)\varpropto p(X|\theta)\pi(\theta) \\\varpropto c^n(\theta)exp\{\phi(\theta)\sum_{i=1}^nT(x_i)\}\prod_{i=1}^nh(x_i)c^{\eta}(\theta)exp\{\phi(\theta)\nu\}\\\varpropto c^{n+\eta}(\theta)exp\{(\sum_{i=1}^nT(x_i)\prod_{i=1}^nh(x_i)+\nu)\phi(\theta)\} π(θ∣X)∝p(X∣θ)π(θ)∝cn(θ)exp{ϕ(θ)∑i=1nT(xi)}∏i=1nh(xi)cη(θ)exp{ϕ(θ)ν}∝cn+η(θ)exp{(∑i=1nT(xi)∏i=1nh(xi)+ν)ϕ(θ)}
可以看到,这和先验分布是同形式的 -
超纲啦。。。
-
假设 λ \lambda λ的先验分布为 π ( λ ) \pi(\lambda) π(λ)
令 X − P ( λ ) X-P(\lambda) X−P(λ)
即 p ( x ∣ λ ) = λ x e − λ Γ ( x + 1 ) p(x|\lambda)=\frac{\lambda^xe^{-\lambda}}{\Gamma(x+1)} p(x∣λ)=Γ(x+1)λxe−λ
可有样本的分布函数为 p ( x ‾ ∣ λ ) = ∏ i = 1 n p ( x i ∣ λ ) = λ ∑ i = 1 n x i e − n λ ∏ i = 1 n Γ ( x i ) p(\overline{x}|\lambda)=\prod_{i=1}^np(x_i|\lambda)=\frac{\lambda^{\sum_{i=1}^nx_i}e^{-n\lambda}}{\prod_{i=1}^n\Gamma(x_i)} p(x∣λ)=∏i=1np(xi∣λ)=∏i=1nΓ(xi)λ∑i=1nxie−nλ
从而有 π ( λ ∣ x ‾ ) ∝ p ( x ∣ λ ) π ( λ ) λ ∑ i = 1 n x i e − n λ π ( λ ) \pi(\lambda|\overline{x})\varpropto p(x|\lambda)\pi(\lambda)\lambda^{\sum_{i=1}^nx_i}e^{-n\lambda}\pi(\lambda) π(λ∣x)∝p(x∣λ)π(λ)λ∑i=1nxie−nλπ(λ)
可以看到,后验分布只与样本的和有关,故可以用样本的和 ∑ i = 1 n x i \sum_{i=1}^nx_i ∑i=1nxi来代替样本,故可证为充分统计量