伯努利模型的极大似然估计和贝叶斯估计

  定义随机变量A为一次伯努利试验的结果, A A A的取值为[0,1],概率分布为 P ( A ) P(A) P(A): P ( A = 1 ) = θ P ( A = 0 ) = 1 − θ P(A=1)=\theta\\P(A=0)=1-\theta P(A=1)=θP(A=0)=1θ下面分别使用极大似然估计和贝叶斯估计来估计 θ \theta θ

  1. 极大似然估计
    L ( θ ) = ∏ i = 1 n P ( A i ) = θ k ( 1 − θ ) n − k L(\theta) = \prod_{i=1}^{n}P(A_i) = \theta^k(1-\theta)^{n-k} L(θ)=i=1nP(Ai)=θk(1θ)nk

A i A_i Ai代表第 i i i次随机试验

l o g L ( θ ) = l o g ∏ i = 1 n P ( A i ) = l o g θ k + l o g ( 1 − θ ) n − k = k l o g θ + ( n − k ) l o g ( 1 − θ ) \begin{aligned} logL(\theta)&=log\prod_{i=1}^{n}P(A_i) = log\theta^k + log(1-\theta)^{n-k}\\ &=klog\theta+(n-k)log(1-\theta) \end{aligned} logL(θ)=logi=1nP(Ai)=logθk+log(1θ)nk=klogθ+(nk)log(1θ)
对公式两边同时求导,并求当导数等于零时的 θ \theta θ值,如下
∂ L ( θ ) ∂ θ = k ⋅ 1 θ + ( n − k ) ⋅ − 1 1 − θ \dfrac{\partial{L(\theta)}}{\partial{\theta}}=k·\dfrac{1}{\theta} + (n-k)·\dfrac{-1}{1-\theta} θL(θ)=kθ1+(nk)1θ1
令 ∂ L ( θ ) ∂ θ = 0 令\dfrac{\partial{L(\theta)}}{\partial{\theta}}=0 θL(θ)=0,可得 θ = k n \theta=\dfrac{k}{n} θ=nk。此时 θ \theta θ满足 θ = arg ⁡ max ⁡ θ L ( θ ) \theta = \mathop{\arg\max} \limits_{\theta}L(\theta) θ=θargmaxL(θ)

  1. 贝叶斯估计
    P ( θ ∣ A 1 , A 2 , … , A n ) = P ( A 1 , A 2 , … , A n ∣ θ ) ⋅ π ( θ ) P ( A 1 , A 2 , … , A n ) P(\theta |A_1,A_2,\dots,A_n)=\dfrac{P(A_1,A_2,\dots,A_n|\theta)·\pi(\theta)}{P(A_1,A_2,\dots,A_n)} P(θA1,A2,,An)=P(A1,A2,,An)P(A1,A2,,Anθ)π(θ)

  根据观察到的结果修正 θ \theta θ,也就是假设 θ \theta θ是随机变量, θ \theta θ服从 β \beta β分布,有很多可能取值,我们要取的值是在已知观察结果的条件下使 θ \theta θ出现概率最大的值。
θ = arg ⁡ max ⁡ θ   P ( A 1 , A 2 , … , A n ∣ θ ) ⋅ P ( θ ) = arg ⁡ max ⁡ θ ∏ P ( A i ∣ θ ) P ( θ ) = arg ⁡ max ⁡ θ θ k ( 1 − θ ) n − k θ a − 1 ( 1 − θ ) b − 1 \begin{aligned} \theta&=\mathop{\arg\max} \limits_{\theta} \ P(A_1,A_2,\dots,A_n|\theta)·P(\theta) \\ &=\mathop{\arg\max} \limits_{\theta} \prod P(A_i|\theta)P(\theta)\\ &=\mathop{\arg\max} \limits_{\theta} \theta^k(1-\theta)^{n-k}\theta^{a-1}(1-\theta)^{b-1} \end{aligned} θ=θargmax P(A1,A2,,Anθ)P(θ)=θargmaxP(Aiθ)P(θ)=θargmaxθk(1θ)nkθa1(1θ)b1

求解同上,得 θ = k + ( a − 1 ) n + ( a − 1 ) + ( b − 1 ) \theta = \dfrac{k+(a-1)}{n+(a-1)+(b-1)} θ=n+(a1)+(b1)k+(a1),其中 a , b a,b a,b β \beta β分布中的参数 β ( θ ; a , b ) = θ a − 1 ( 1 − θ ) b − 1 C \beta(\theta;a,b)=\dfrac{\theta^{a-1}(1-\theta)^{b-1}}{C} β(θ;a,b)=Cθa1(1θ)b1, C C C为常数,选定 a , b a,b a,b后就可以确定 θ \theta θ

你可能感兴趣的:(伯努利模型的极大似然估计和贝叶斯估计)