前言
这篇博客中,我主要想复习一下极大似然估计(maximum likelihood estimation, MLE)和最大后验估计(maximum a posteriori estimation, MAP)。
MLE
似然函数
假设我么现在有一个随机变量X X X 的pdf或者分布律P ( X ∣ θ ) P(X\mid \theta) P ( X ∣ θ ) ,其中θ \theta θ 是X X X 的分布所需要的参数。
对于一个服从泊松分布的随机变量X ∼ P o ( λ ) X\sim \mathrm{Po}(\lambda) X ∼ Po ( λ ) ,θ \theta θ 为λ \lambda λ 。对于一个服从高斯分布的随机变量X ∼ N ( μ , σ 2 ) X \sim \mathcal{N}(\mu, \sigma^{2}) X ∼ N ( μ , σ 2 ) ,θ \theta θ 就是一个参数向量[ μ , σ 2 ] ⊤ [\mu, \sigma^{2}]^{\top} [ μ , σ 2 ] ⊤ 。
对P ( X ∣ θ ) P(X \mid \theta) P ( X ∣ θ ) ,我们可以看作,当给定参数θ \theta θ 之后,X X X 的取值函数。
更进一步,P ( X ∣ θ ) P(X \mid \theta) P ( X ∣ θ ) 表示,当给定参数θ \theta θ 之后,X X X 的取值x x x 出现的可能性。
如果我们不拘泥于概率密度函数,而是更一般的函数f ( x ) f(x) f ( x ) ,我们会发现将参数和变量分开的写法很有一般性。
比如说,我们考虑一个线性函数
f ( x ) = β 0 + β 1 x , f(x) = \beta_{0} + \beta_{1}x,
f ( x ) = β 0 + β 1 x ,
这里可以仿照概率函数的写法写作
f ( x ∣ B = [ β 0 , β 1 ] ⊤ ) . f(x \mid \boldsymbol{B} = [\beta_0, \beta_{1}]^{\top}).
f ( x ∣ B = [ β 0 , β 1 ] ⊤ ) .
相当于,给定β 0 \beta_{0} β 0 和β 1 \beta_{1} β 1
之后,根据x x x 的取值,得到对应的函数值。
接下来我们回到P ( X ∣ θ ) P(X \mid \theta) P ( X ∣ θ ) 。我们目前已知讨论的固定θ \theta θ ,改变X X X 的取值。但实际上P ( X ∣ θ ) P(X \mid \theta) P ( X ∣ θ ) 是一个由X = x X=x X = x 和θ \theta θ 共同构成的函数。
例如,对于高斯分布N ( μ , σ 2 ) \mathcal{N}(\mu, \sigma^{2}) N ( μ , σ 2 ) ,我们有
P ( X = x ∣ [ μ , σ 2 ] ⊤ ) = 1 2 π σ 2 exp ( − 1 2 ⋅ ( x − μ ) 2 σ 2 ) . P(X=x \mid [\mu, \sigma^{2}]^{\top}) = \frac{1}{\sqrt{2\pi\sigma^{2}}}\exp{\left(-\frac{1}{2}\cdot\frac{(x-\mu)^{2}}{\sigma^{2}}\right)}.
P ( X = x ∣ [ μ , σ 2 ] ⊤ ) = 2 π σ 2 1 exp ( − 2 1 ⋅ σ 2 ( x − μ ) 2 ) .
对于上面这个pdf,我们写作
P ( x , μ , σ 2 ) P(x, \mu, \sigma^{2})
P ( x , μ , σ 2 )
其实也未尝不可。
此时,我们从X X X 里抽一个样本x 1 x_{1} x 1 ,代入P ( x , μ , σ 2 ) P(x, \mu, \sigma^{2}) P ( x , μ , σ 2 ) ,并把该函数想象成关于μ \mu μ 和σ 2 \sigma^{2} σ 2 的函数,
我们有
P ( x , μ , σ 2 ) = L ( [ μ , σ 2 ] ⊤ ∣ x 1 ) . P(x, \mu, \sigma^{2}) = L\left([\mu, \sigma^{2}]^{\top} \mid x_{1}\right).
P ( x , μ , σ 2 ) = L ( [ μ , σ 2 ] ⊤ ∣ x 1 ) .
这里的L ( [ μ , σ 2 ] ⊤ ∣ x 1 ) L\left([\mu, \sigma^{2}]^{\top} \mid x_{1}\right) L ( [ μ , σ 2 ] ⊤ ∣ x 1 ) ,可以看作给定X = x 1 X=x_{1} X = x 1 时,[ μ , σ 2 ] ⊤ [\mu, \sigma^{2}]^{\top} [ μ , σ 2 ] ⊤ 对这个观测值的支持程度。
我们一般称呼它为似然函数 。
注意这里我们没有用可能性或者概率去描述和称呼,这是因为当x 1 x_{1} x 1 被给定之后,对所有的可能的[ μ , σ 2 ] ⊤ [\mu, \sigma^{2}]^{\top} [ μ , σ 2 ] ⊤ 求积分得到的结果可能不为1 1 1 。
举个例子,为了方便,我们假设高斯分布的μ \mu μ 已知,然后给定X = x 1 X = x_{1} X = x 1 之后,我们有
L ( σ 2 ∣ x 1 , μ ) = 1 2 π σ 2 exp ( − 1 2 ⋅ ( x 1 − μ ) 2 σ 2 ) . \begin{aligned}
L(\sigma^{2} \mid x_{1}, \mu) &= \frac{1}{\sqrt{2\pi\sigma^{2}}}\exp{\left(-\frac{1}{2}\cdot\frac{(x_1-\mu)^{2}}{\sigma^{2}}\right)}.
\end{aligned}
L ( σ 2 ∣ x 1 , μ ) = 2 π σ 2 1 exp ( − 2 1 ⋅ σ 2 ( x 1 − μ ) 2 ) .
然后我们在σ ∈ [ 0 , + ∞ ) \sigma\in [0, +\infty ) σ ∈ [ 0 , + ∞ ) 上求积分。
先令a = x 1 − μ a = x_{1} - \mu a = x 1 − μ ,我们有
∫ 0 + ∞ L ( σ 2 ∣ x 1 , μ ) d σ = ∫ 0 + ∞ 1 2 π σ 2 exp ( − a 2 2 σ 2 ) d σ = 1 2 π ∫ 0 + ∞ 1 σ exp ( − a 2 2 σ 2 ) d σ \begin{aligned}
\int_{0}^{+\infty } L(\sigma^{2} \mid x_{1}, \mu) d\sigma &= \int_{0}^{+\infty } \frac{1}{\sqrt{2\pi\sigma^{2}}}\exp{\left(-\frac{a^{2}}{2\sigma^{2}}\right)} d\sigma \\
&= \frac{1}{\sqrt{2\pi}} \int_{0}^{+\infty } \frac{1}{\sigma}\exp{\left(-\frac{a^{2}}{2\sigma^{2}}\right)} d\sigma
\end{aligned}
∫ 0 + ∞ L ( σ 2 ∣ x 1 , μ ) d σ = ∫ 0 + ∞ 2 π σ 2 1 exp ( − 2 σ 2 a 2 ) d σ = 2 π 1 ∫ 0 + ∞ σ 1 exp ( − 2 σ 2 a 2 ) d σ
我们发现,
lim σ → + ∞ exp ( − a 2 2 σ 2 ) = 1 \lim_{\sigma\to +\infty } \exp{\left( -\frac{a^{2}}{2\sigma^{2}}\right)} = 1
σ → + ∞ lim exp ( − 2 σ 2 a 2 ) = 1
这意味着存在一个M M M ,当σ > M \sigma > M σ > M 的时候,
exp ( − a 2 2 σ 2 ) > 1 2 . \exp{\left( -\frac{a^{2}}{2\sigma^{2}}\right)} > \frac{1}{2}.
exp ( − 2 σ 2 a 2 ) > 2 1 .
所以我们有
1 2 π ∫ M + ∞ 1 σ exp ( − a 2 2 σ 2 ) d σ > 1 2 2 π ∫ M + ∞ 1 σ d σ = + ∞ \frac{1}{\sqrt{2\pi}} \int_{M}^{+\infty } \frac{1}{\sigma}\exp{\left(-\frac{a^{2}}{2\sigma^{2}}\right)} d\sigma > \frac{1}{2\sqrt{2\pi}} \int_{M}^{+\infty } \frac{1}{\sigma} d\sigma = + \infty
2 π 1 ∫ M + ∞ σ 1 exp ( − 2 σ 2 a 2 ) d σ > 2 2 π 1 ∫ M + ∞ σ 1 d σ = + ∞
对于σ ∈ [ 0 , M ] \sigma \in [0, M] σ ∈ [ 0 , M ] 的部分,积分值一定大于0 0 0 。
结合起来我们有
1 2 π ∫ 0 + ∞ 1 σ exp ( − a 2 2 σ 2 ) d σ = + ∞ . \frac{1}{\sqrt{2\pi}} \int_{0}^{+\infty } \frac{1}{\sigma}\exp{\left(-\frac{a^{2}}{2\sigma^{2}}\right)} d\sigma = + \infty .
2 π 1 ∫ 0 + ∞ σ 1 exp ( − 2 σ 2 a 2 ) d σ = + ∞.
所以我们可以说明L ( σ 2 ∣ x 1 , μ ) L(\sigma^{2} \mid x_{1}, \mu) L ( σ 2 ∣ x 1 , μ ) 不满足归一化公理,自然也就不是一个概率。
但也有可以归一化的情况,
假设高斯分布的σ 2 \sigma^{2} σ 2 已知,然后给定X = x 1 X = x_{1} X = x 1 之后,我们有
L ( μ ∣ x 1 , σ 2 ) = 1 2 π σ 2 exp ( − 1 2 ⋅ ( x 1 − μ ) 2 σ 2 ) . \begin{aligned}
L(\mu \mid x_{1}, \sigma^{2}) &= \frac{1}{\sqrt{2\pi\sigma^{2}}}\exp{\left(-\frac{1}{2}\cdot\frac{(x_1-\mu)^{2}}{\sigma^{2}}\right)}.
\end{aligned}
L ( μ ∣ x 1 , σ 2 ) = 2 π σ 2 1 exp ( − 2 1 ⋅ σ 2 ( x 1 − μ ) 2 ) .
然后我们在μ ∈ R \mu\in \mathbb{R} μ ∈ R 上求积分
∫ R L ( μ ∣ x 1 , σ 2 ) d μ = ∫ R 1 2 π σ 2 exp ( − 1 2 ⋅ ( x 1 − μ ) 2 σ 2 ) d μ = t = x 1 − μ 1 2 π σ 2 ∫ + ∞ − ∞ exp ( − 1 2 ⋅ t 2 σ 2 ) ( − d t ) = 1 2 π σ 2 ∫ R exp ( − 1 2 ⋅ t 2 σ 2 ) d t \begin{aligned}
\int_{\mathbb{R}} L(\mu \mid x_{1}, \sigma^{2}) d\mu &= \int_{\mathbb{R}} \frac{1}{\sqrt{2\pi\sigma^{2}}}\exp{\left(-\frac{1}{2}\cdot\frac{(x_1-\mu)^{2}}{\sigma^{2}}\right)} d\mu \\
&\overset{t=x_{1}-\mu}{=} \frac{1}{\sqrt{2\pi\sigma^{2}}}\int_{+\infty }^{-\infty }\exp{\left(-\frac{1}{2}\cdot\frac{t^{2}}{\sigma^{2}}\right)} (-dt) \\
&= \frac{1}{\sqrt{2\pi\sigma^{2}}}\int_{\mathbb{R}} \exp{\left(-\frac{1}{2}\cdot\frac{t^{2}}{\sigma^{2}}\right)} dt
\end{aligned}
∫ R L ( μ ∣ x 1 , σ 2 ) d μ = ∫ R 2 π σ 2 1 exp ( − 2 1 ⋅ σ 2 ( x 1 − μ ) 2 ) d μ = t = x 1 − μ 2 π σ 2 1 ∫ + ∞ − ∞ exp ( − 2 1 ⋅ σ 2 t 2 ) ( − d t ) = 2 π σ 2 1 ∫ R exp ( − 2 1 ⋅ σ 2 t 2 ) d t
对于∫ R exp ( − 1 2 ⋅ t 2 σ 2 ) d t \int_{\mathbb{R}}\exp{\left(-\frac{1}{2}\cdot\frac{t^{2}}{\sigma^{2}}\right)} dt ∫ R exp ( − 2 1 ⋅ σ 2 t 2 ) d t ,
我们先求
∫ R ∫ R exp ( − t 1 2 2 σ 2 ) exp ( − t 2 2 2 σ 2 ) d t 1 d t 2 = ∫ R ∫ R exp ( − t 1 2 + t 2 2 2 σ 2 ) d t 1 d t 2 = ∫ 0 2 π d θ ∫ 0 + ∞ r ⋅ exp ( − r 2 2 σ 2 ) d r = 2 π ⋅ ( − σ 2 ) ∫ 0 + ∞ exp ( − r 2 2 σ 2 ) d ( − r 2 2 σ 2 ) = − 2 π σ 2 exp ( − r 2 2 σ 2 ) ∣ 0 + ∞ = 2 π σ 2 \begin{aligned}
& \quad \int_{\mathbb{R}}\int_{\mathbb{R}} \exp{\left( -\frac{t_{1}^{2}}{2\sigma^{2}}\right)}\exp{\left( -\frac{t_{2}^{2}}{2\sigma^{2}}\right)}\, dt_{1}dt_{2} \\
&= \int_{\mathbb{R}}\int_{\mathbb{R}} \exp{\left( -\frac{t_{1}^{2}+t^{2}_{2}}{2\sigma^{2}}\right)}\, dt_{1}dt_{2} \\
&= \int_{0}^{2\pi}d\theta\int_{0}^{+\infty } r \cdot\exp{\left( - \frac{r^{2}}{2\sigma^{2}} \right)}\, dr \\
&= 2\pi\cdot (-\sigma^{2}) \int_{0}^{+\infty } \exp{\left( - \frac{r^{2}}{2\sigma^{2}} \right)} \, d\left(-\frac{r^{2}}{2\sigma^{2}}\right) \\
&= -2\pi\sigma^{2} \exp{\left( - \frac{r^{2}}{2\sigma^{2}} \right)} \Bigg\vert^{+\infty }_{0} \\
&= 2\pi\sigma^{2}
\end{aligned}
∫ R ∫ R exp ( − 2 σ 2 t 1 2 ) exp ( − 2 σ 2 t 2 2 ) d t 1 d t 2 = ∫ R ∫ R exp ( − 2 σ 2 t 1 2 + t 2 2 ) d t 1 d t 2 = ∫ 0 2 π d θ ∫ 0 + ∞ r ⋅ exp ( − 2 σ 2 r 2 ) d r = 2 π ⋅ ( − σ 2 ) ∫ 0 + ∞ exp ( − 2 σ 2 r 2 ) d ( − 2 σ 2 r 2 ) = − 2 π σ 2 exp ( − 2 σ 2 r 2 ) 0 + ∞ = 2 π σ 2
所以有
∫ R exp ( − 1 2 ⋅ t 2 σ 2 ) d t = 2 π σ 2 \int_{\mathbb{R}}\exp{\left(-\frac{1}{2}\cdot\frac{t^{2}}{\sigma^{2}}\right)} dt = \sqrt{2\pi\sigma^{2}}
∫ R exp ( − 2 1 ⋅ σ 2 t 2 ) d t = 2 π σ 2
将结果代回∫ R L ( μ ∣ x 1 , σ 2 ) d μ \int_{\mathbb{R}} L(\mu \mid x_{1}, \sigma^{2}) d\mu ∫ R L ( μ ∣ x 1 , σ 2 ) d μ 之后,得到
∫ R L ( μ ∣ x 1 , σ 2 ) d μ = 1 2 π σ 2 2 π σ 2 = 1. \int_{\mathbb{R}} L(\mu \mid x_{1}, \sigma^{2}) d\mu = \frac{1}{\sqrt{2\pi\sigma^{2}}}\sqrt{2\pi\sigma^{2}} = 1.
∫ R L ( μ ∣ x 1 , σ 2 ) d μ = 2 π σ 2 1 2 π σ 2 = 1.
不拘泥于高斯分布,我么可以用
L ( θ ∣ x 1 ) L\left(\theta \mid x_{1}\right)
L ( θ ∣ x 1 )
来表示似然函数 。
极大似然
回到MLE的话题上,当我们有似然函数L ( θ ∣ x 1 ) L\left(\theta \mid x_{1}\right) L ( θ ∣ x 1 ) 之后,我们可以找到使L ( θ ∣ x 1 ) L\left(\theta \mid x_{1}\right) L ( θ ∣ x 1 ) 最大的θ ∗ \theta^{*} θ ∗ ,也就是对x 1 x_1 x 1 这个观测值的支持程度达到最大。
此时,我们认为给定x 1 x_{1} x 1 的时候,θ ∗ \theta^{*} θ ∗ 是最优的估计值。
我们换一个角度来直觉上的理解支持程度达到最大这个表述。
我们之前有讨论过L ( θ ∣ x 1 ) L\left(\theta \mid x_{1}\right) L ( θ ∣ x 1 ) 也许并不满足归一化,所以不能直接称作概率。
但是如果我们将似然函数改造为
L ~ ( θ ∣ x 1 ) = L ( θ ∣ x 1 ) ∫ θ L ( θ ∣ x 1 ) d θ , \widetilde{L}\left(\theta \mid x_{1}\right) = \frac{L\left(\theta \mid x_{1}\right)}{\int_{\theta}L\left(\theta \mid x_{1}\right) d\theta},
L ( θ ∣ x 1 ) = ∫ θ L ( θ ∣ x 1 ) d θ L ( θ ∣ x 1 ) ,
我们会得到形式上相似的参数的密度函数。
利用这个函数,我们的θ ∗ \theta^{*} θ ∗ 应该为
θ ∗ = arg max θ L ~ ( θ ∣ x 1 ) = arg max θ L ( θ ∣ x 1 ) ∫ θ L ( θ ∣ x 1 ) d θ = arg max θ L ( θ ∣ x 1 ) . \begin{aligned}
\theta^{*} &= \arg \max_{\theta} \widetilde{L}\left(\theta \mid x_{1}\right) \\
&= \arg \max_{\theta} \frac{L\left(\theta \mid x_{1}\right)}{\int_{\theta}L\left(\theta \mid x_{1}\right) d\theta} \\
&= \arg \max_{\theta} L\left(\theta \mid x_{1}\right).
\end{aligned}
θ ∗ = arg θ max L ( θ ∣ x 1 ) = arg θ max ∫ θ L ( θ ∣ x 1 ) d θ L ( θ ∣ x 1 ) = arg θ max L ( θ ∣ x 1 ) .
最后一步的推导主要是因为∫ θ L ( θ ∣ x 1 ) d θ \int_{\theta}L\left(\theta \mid x_{1}\right)d\theta ∫ θ L ( θ ∣ x 1 ) d θ 是与θ \theta θ 无关的一个值,所以有
L ( θ ∣ x 1 ) ∝ L ( θ ∣ x 1 ) ∫ θ L ( θ ∣ x 1 ) d θ . L\left(\theta \mid x_{1}\right) \propto \frac{L\left(\theta \mid x_{1}\right)}{\int_{\theta}L\left(\theta \mid x_{1}\right) d\theta}.
L ( θ ∣ x 1 ) ∝ ∫ θ L ( θ ∣ x 1 ) d θ L ( θ ∣ x 1 ) .
但需要注意的是,L ~ ( θ ∣ x 1 ) \widetilde{L}\left(\theta \mid x_{1}\right) L ( θ ∣ x 1 ) 并不是我们接下来要讲的后验分布,
在做统计估计的时候,当只有一个样本的时候,估计很可能是不准确的,所以我们要大量采样。
假设我们进行独立随机采样得到的样本为x = { x i } N \boldsymbol{x}=\{x_{i}\}_{N} x = { x i } N 。
给定每一个样本我们有
{ L ( θ ∣ x i ) } N . \begin{aligned}
\left\{L\left(\theta \mid x_{i}\right)\right\}_{N}.
\end{aligned}
{ L ( θ ∣ x i ) } N .
进一步因为是随机采样,我们有
L ( θ ∣ x ) = L ( θ ∣ { x 1 , x 2 , … , x N } ) = ∏ i N L ( θ ∣ x i ) . \begin{aligned}
L\left(\theta \mid \boldsymbol{x}\right) &= L\left(\theta \mid \{x_{1}, x_{2}, \dots, x_{N}\}\right) \\
&=\prod_{i}^{N} L\left(\theta \mid x_{i}\right).
\end{aligned}
L ( θ ∣ x ) = L ( θ ∣ { x 1 , x 2 , … , x N } ) = i ∏ N L ( θ ∣ x i ) .
连乘的计算很多时候并不方便,我们可以通过引入一个单增的log函数来进行转化。
最后θ ∗ \theta^{*} θ ∗ 的估计可以写作
θ ^ ∗ = arg max θ log ( L ( θ ∣ x ) ) = arg max θ log ( ∏ i N L ( θ ∣ x i ) ) = arg max θ ∑ i N log ( L ( θ ∣ x i ) ) . \begin{aligned}
\widehat{\theta}^{*} &= \arg \max_{\theta} \log\left( L\left(\theta \mid \boldsymbol{x}\right)\right)\\
&= \arg \max_{\theta} \log \left(\prod_{i}^{N} L\left(\theta \mid x_{i}\right) \right)\\
&= \arg \max_{\theta} \sum_{i}^{N}\log \left(L(\theta\mid x_{i})\right).
\end{aligned}
θ ∗ = arg θ max log ( L ( θ ∣ x ) ) = arg θ max log ( i ∏ N L ( θ ∣ x i ) ) = arg θ max i ∑ N log ( L ( θ ∣ x i ) ) .
MAP
接下来我们讲一下最大后验。
假设我们现在有一组采样数据x \boldsymbol{x} x ,我们像估计这组数据背后的分布的参数θ \theta θ 。
在MLE中我们直接使用似然函数L ( θ ∣ x ) L\left(\theta \mid \boldsymbol{x}\right) L ( θ ∣ x ) 来进行估计。
我们对θ \theta θ 的估计完全根据数据x \boldsymbol{x} x 。
但如果我们对θ \theta θ 其实并不是完全无知呢?
比如说,我捡到一个硬币,我可能会很先入为主的认为如果我抛掷这枚硬币的话,得到正面的概率为1 2 \frac{1}{2} 2 1 。
如果用MLE的话,接下来我会大量抛硬币然后进行参数估计。注意到在这个过程中,我先入为主的猜测并不会影响MLE的估计。
我想知道我先入为主的猜测是否可以影响估计参数。
如果猜测很准的话,可能对参数估计有极大帮助。如果猜测的不准的话,也没关系,后面大量实验会帮我修正我的猜测。
将我们的猜测引入参数估计的一种方法便是极大后验估计。
我们先引入贝叶斯公式
P ( θ ∣ x ) = P ( x ∣ θ ) P ( θ ) P ( x ) = L ( θ ∣ x ) P ( θ ) P ( x ) , P(\theta \mid \boldsymbol{x}) = \frac{P(\boldsymbol{x} \mid \theta)P(\theta)}{P(\boldsymbol{x})} = \frac{L(\theta \mid \boldsymbol{x})P(\theta)}{P(\boldsymbol{x})},
P ( θ ∣ x ) = P ( x ) P ( x ∣ θ ) P ( θ ) = P ( x ) L ( θ ∣ x ) P ( θ ) ,
其中,我的猜测便是P ( θ ) P(\theta) P ( θ ) ,我们一般把这个分布称为先验分布,或者我更喜欢信念(belief)这个名字。
P ( x ∣ θ ) P(\boldsymbol{x}\mid \theta) P ( x ∣ θ ) 变为之前介绍过的似然函数。P ( x ) P(\boldsymbol{x}) P ( x ) 是x \boldsymbol{x} x 的概率分布,或者叫作边际似然。
最后,P ( θ ∣ x ) P(\theta \mid \boldsymbol{x}) P ( θ ∣ x ) 被叫做引入信念之后的θ \theta θ 的后验分布。
最大后验顾名思义就是通过
θ ∗ = arg max θ P ( θ ∣ x ) = arg max θ P ( x ∣ θ ) P ( θ ) P ( x ) , \theta^{*}=\arg \max_{\theta} P(\theta \mid \boldsymbol{x})= \arg \max_{\theta} \frac{P(\boldsymbol{x} \mid \theta)P(\theta)}{P(\boldsymbol{x})},
θ ∗ = arg θ max P ( θ ∣ x ) = arg θ max P ( x ) P ( x ∣ θ ) P ( θ ) ,
其中P ( x ) P(\boldsymbol{x}) P ( x ) 是一个与θ \theta θ 无关的分布,如在MLE中讲的相似,可以认为P ( x ) P(\boldsymbol{x}) P ( x ) 起到一个归一化的作用。
所以,
θ ∗ = arg max θ P ( x ∣ θ ) P ( θ ) . \theta^{*}=\arg \max_{\theta} P(\boldsymbol{x} \mid \theta)P(\theta).
θ ∗ = arg θ max P ( x ∣ θ ) P ( θ ) .
同样的,x \boldsymbol{x} x 是随机独立采样而来的,因此,
θ ∗ = arg max θ P ( θ ) ∏ i N P ( x i ∣ θ ) = arg max θ P ( θ ) ( ∏ i N L ( θ ∣ x i ) ) . \theta^{*}=\arg \max_{\theta} P(\theta)\prod_{i}^{N} P(x_{i} \mid \theta) = \arg \max_{\theta} P(\theta) \left(\prod_{i}^{N} L\left(\theta \mid x_{i}\right)\right).
θ ∗ = arg θ max P ( θ ) i ∏ N P ( x i ∣ θ ) = arg θ max P ( θ ) ( i ∏ N L ( θ ∣ x i ) ) .
可以看到,比起MLE,MAP的优化函数中多了P ( θ ) P(\theta) P ( θ ) 的部分。
注意,似然函数和信念都是我们事先假设的。