上一节介绍了高斯分布概率模型相关的推断问题,并详细介绍了给定联合概率分布求解条件概率分布。本节将继续介绍推断任务——基于随机变量之间存在线性关系的条件下,求解条件概率与边缘概率。
卡尔曼滤波(Kalman Filter)本身是线性高斯动态模型(Linear Gaussian Dynamic Model)的代表,它的性质表示在如下过程:
状态转移概率 P ( i t ∣ i t − 1 ) \mathcal P(i_t \mid i_{t-1}) P(it∣it−1):
需要注意的点:卡尔曼滤波是‘动态模型’的一种表达,它依然受到‘齐次马尔可夫假设’的约束。
以一阶齐次马尔可夫假设为例,线性高斯动态模型中的相邻隐变量之间存在线性关系,并且对应噪声 ϵ \epsilon ϵ服从高斯分布:
i t = A ⋅ i t − 1 + B + ϵ ϵ ∼ N ( 0 , Q ) i_t = \mathcal A \cdot i_{t-1} + \mathcal B + \epsilon \quad \epsilon \sim \mathcal N(0,\mathcal Q) it=A⋅it−1+B+ϵϵ∼N(0,Q)
对应概率分布表示如下:
这种表示方法需要注意。它写的是
N ( A ⋅ i t − 1 + B , Q ) \mathcal N(\mathcal A \cdot i_{t-1} + \mathcal B,\mathcal Q) N(A⋅it−1+B,Q)而不是
A μ + B \mathcal A \mu + \mathcal B Aμ+B。因为
N ( A μ + B , A Q A T ) \mathcal N(\mathcal A \mu + \mathcal B,\mathcal A\mathcal Q\mathcal A^T) N(Aμ+B,AQAT)表示
i t i_t it的边缘概率分布。并且,这种写法意味着
i t − 1 i_{t-1} it−1是已知的,可观测的。
{ P ( i t − 1 ) ∼ N ( μ , Q ) P ( i t ∣ i t − 1 ) ∼ N ( A ⋅ i t − 1 + B , Q ) \begin{cases} \mathcal P(i_{t-1}) \sim \mathcal N(\mu,\mathcal Q) \\ \mathcal P(i_{t} \mid i_{t-1}) \sim \mathcal N(\mathcal A \cdot i_{t-1} + \mathcal B,\mathcal Q) \end{cases} {P(it−1)∼N(μ,Q)P(it∣it−1)∼N(A⋅it−1+B,Q)
这个式子表示的是关于随机变量自身的线性关系还是期望的线性关系?使用例子描述一下:
均值由0变成了 2x0+2=2。
需要再次强调,
P ( i t ) , P ( i t ∣ i t − 1 ) \mathcal P(i_{t}),\mathcal P(i_t \mid i_{t-1}) P(it),P(it∣it−1)它们两个代表不同的高斯分布。而
A Q A T \mathcal A\mathcal Q\mathcal A^T AQAT是‘基于’
i t = A ⋅ i t − 1 + B i_t = \mathcal A \cdot i_{t-1} + \mathcal B it=A⋅it−1+B线性计算的关于
i t i_t it的边缘概率分布
P ( i t ) \mathcal P(i_t) P(it)的协方差结果。
发射概率 P ( o t ∣ i t ) \mathcal P(o_t \mid i_t) P(ot∣it)
隐变量与对应时刻观测变量之间存在线性关系,斌且噪声服从高斯分布:
{ o t = C ⋅ i t + D + δ δ ∼ N ( 0 , R ) P ( o t ∣ i t ) ∼ N ( C ⋅ i t + D , R ) \begin{cases} o_t = \mathcal C \cdot i_t + \mathcal D + \delta \quad \delta \sim \mathcal N(0,\mathcal R) \\ \mathcal P(o_t \mid i_t) \sim \mathcal N(\mathcal C \cdot i_t + \mathcal D,\mathcal R) \end{cases} {ot=C⋅it+D+δδ∼N(0,R)P(ot∣it)∼N(C⋅it+D,R)
当某随机变量 X \mathcal X X服从高斯分布,并且随机变量 Y \mathcal Y Y与随机变量 X \mathcal X X之间存在线性关系时:
{ X ∼ N ( μ , Σ ) Y = A X + B \begin{cases} \mathcal X \sim \mathcal N(\mu,\Sigma) \\ \mathcal Y = \mathcal A \mathcal X + \mathcal B \end{cases} {X∼N(μ,Σ)Y=AX+B
那么随机变量 Y \mathcal Y Y同样服从高斯分布:
需要注意这里的表示,随机变量
Y \mathcal Y Y的概率分布服从高斯分布,这里的‘概率分布’仅仅是
Y \mathcal Y Y自身的分布,可以理解为‘边缘概率分布’。
Y ∼ N ( A μ + B , A Σ A T ) \mathcal Y \sim \mathcal N(\mathcal A\mu + \mathcal B,\mathcal A \Sigma\mathcal A^T) Y∼N(Aμ+B,AΣAT)
这同样引出期望、协方差在线性计算中的表达:
{ E P ( Y ) = E P ( X ) [ A X + B ] = A ⋅ E P ( X ) [ X ] + B = A μ + B Var ( Y ) = Var ( A X + B ) = Var ( A X ) + Var ( B ) = Var ( A X ) = A Σ A T \begin{cases} \begin{aligned}\mathbb E_{\mathcal P(\mathcal Y)} & = \mathbb E_{\mathcal P(\mathcal X)}[\mathcal A \mathcal X + \mathcal B] \\ & = \mathcal A \cdot \mathbb E_{\mathcal P(\mathcal X)}[\mathcal X] + \mathcal B \\ & = \mathcal A \mu + \mathcal B \end{aligned} \\ \begin{aligned} \text{Var}(\mathcal Y) & = \text{Var}(\mathcal A \mathcal X + \mathcal B) \\ & = \text{Var}(\mathcal A \mathcal X) + \text{Var}(\mathcal B) \\ & = \text{Var}(\mathcal A \mathcal X) \\ & = \mathcal A \Sigma\mathcal A^T \end{aligned} \end{cases} ⎩⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎧EP(Y)=EP(X)[AX+B]=A⋅EP(X)[X]+B=Aμ+BVar(Y)=Var(AX+B)=Var(AX)+Var(B)=Var(AX)=AΣAT
给定随机变量 X \mathcal X X的概率分布结果与随机变量 Y \mathcal Y Y基于 X \mathcal X X的概率分布结果:
其中
Λ − 1 , L − 1 \Lambda^{-1},\mathcal L^{-1} Λ−1,L−1分别表示
P ( X ) , P ( Y ∣ X ) \mathcal P(\mathcal X),\mathcal P(\mathcal Y \mid \mathcal X) P(X),P(Y∣X)概率分布的精度矩阵
(Precision Matrix)。它本身表示‘协方差矩阵’的逆矩阵。在高斯图模型中对非零边进行编码。
这里仅需要知道
P ( X ) , P ( Y ∣ X ) \mathcal P(\mathcal X),\mathcal P(\mathcal Y \mid \mathcal X) P(X),P(Y∣X)的协方差矩阵使用精度矩阵表示,并且
Λ − 1 , L − 1 \Lambda^{-1},\mathcal L^{-1} Λ−1,L−1之间不存在关联即可。在后续的‘高斯网络’中可能会介绍到。
P ( X ) ∼ N ( μ , Λ − 1 ) P ( Y ∣ X ) ∼ N ( A X + B , L − 1 ) \begin{aligned} \mathcal P(\mathcal X) & \sim \mathcal N(\mu,\Lambda^{-1}) \\ \mathcal P(\mathcal Y \mid \mathcal X) & \sim \mathcal N(\mathcal A \mathcal X + \mathcal B,\mathcal L^{-1}) \end{aligned} P(X)P(Y∣X)∼N(μ,Λ−1)∼N(AX+B,L−1)
基于上述条件,求解随机变量 Y \mathcal Y Y的边缘概率分布 P ( Y ) \mathcal P(\mathcal Y) P(Y)与条件概率分布 P ( X ∣ Y ) \mathcal P(\mathcal X \mid \mathcal Y) P(X∣Y)。
根据上述条件以及回顾中提到的 线性高斯模型中随机变量之间的关联关系,随机变量 X , Y \mathcal X,\mathcal Y X,Y之间关联关系表示如下:
其中这里的
ϵ \epsilon ϵ表示噪声的分布。
Y = A X + B + ϵ ϵ ∼ N ( 0 , L − 1 ) \mathcal Y = \mathcal A \mathcal X + \mathcal B + \epsilon \quad \epsilon \sim \mathcal N(0,\mathcal L^{-1}) Y=AX+B+ϵϵ∼N(0,L−1)
因此随机变量 Y \mathcal Y Y的期望结果表示如下:
E P ( Y ) [ Y ] = E P ( X ) [ A X + B + ϵ ] = E P ( X ) [ A X + B ] + E [ ϵ ] ⏟ 0 = A μ + B \begin{aligned} \mathbb E_{\mathcal P(\mathcal Y)}[\mathcal Y] & = \mathbb E_{\mathcal P(\mathcal X)}[\mathcal A \mathcal X + \mathcal B + \epsilon] \\ & = \mathbb E_{\mathcal P(\mathcal X)}[\mathcal A\mathcal X + \mathcal B] + \underbrace{\mathbb E[\epsilon]}_{0} \\ & = \mathcal A \mu + \mathcal B \end{aligned} EP(Y)[Y]=EP(X)[AX+B+ϵ]=EP(X)[AX+B]+0 E[ϵ]=Aμ+B
随机变量 Y \mathcal Y Y的协方差结果表示如下:
Var ( Y ) = Var ( A X + B + ϵ ) = Var ( A X + B ) + Var ( ϵ ) = A Λ − 1 A T + L − 1 \begin{aligned} \text{Var}(\mathcal Y) & = \text{Var}(\mathcal A \mathcal X + \mathcal B + \epsilon) \\ & = \text{Var}(\mathcal A\mathcal X + \mathcal B) + \text{Var}(\epsilon) \\ & = \mathcal A \Lambda^{-1}\mathcal A^T + \mathcal L^{-1} \end{aligned} Var(Y)=Var(AX+B+ϵ)=Var(AX+B)+Var(ϵ)=AΛ−1AT+L−1
至此,随机变量 Y \mathcal Y Y的边缘概率分布 P ( Y ) \mathcal P(\mathcal Y) P(Y)服从如下分布:
P ( Y ) ∼ N ( A μ + B , A Λ − 1 A T + L − 1 ) \mathcal P(\mathcal Y) \sim \mathcal N(\mathcal A \mu + \mathcal B, \mathcal A \Lambda^{-1}\mathcal A^T + \mathcal L^{-1}) P(Y)∼N(Aμ+B,AΛ−1AT+L−1)
不同上一节中给定联合概率分布,求解条件概率分布,此时给定的是 P ( Y ∣ X ) , P ( X ) \mathcal P(\mathcal Y \mid \mathcal X),\mathcal P(\mathcal X) P(Y∣X),P(X),求解 P ( X ∣ Y ) \mathcal P(\mathcal X \mid \mathcal Y) P(X∣Y)。
由于边缘概率分布 P ( Y ) \mathcal P(\mathcal Y) P(Y)已经求出,至此定义一个 Z \mathcal Z Z向量将随机变量 X , Y \mathcal X,\mathcal Y X,Y组合成一个向量:
Z = ( X , Y ) T \mathcal Z = (\mathcal X,\mathcal Y)^T Z=(X,Y)T
因此, Z \mathcal Z Z的概率分布表示如下:
直接可以将
Z \mathcal Z Z的概率分布看成‘联合概率分布’。
Z = ( X Y ) ∼ N ( [ μ A ⋅ μ + B ] , [ Λ − 1 , Δ Δ T , L − 1 + A Λ − 1 A T ] ) \mathcal Z = \begin{pmatrix}\mathcal X \\ \mathcal Y\end{pmatrix} \sim \mathcal N\left(\begin{bmatrix}\mu \\ \mathcal A \cdot \mu + \mathcal B\end{bmatrix}, \begin{bmatrix}\Lambda^{-1},\Delta \\ \Delta^T,\mathcal L^{-1} + \mathcal A \Lambda^{-1}\mathcal A^T\end{bmatrix}\right) Z=(XY)∼N([μA⋅μ+B],[Λ−1,ΔΔT,L−1+AΛ−1AT])
对于这个联合概率分布,期望部分全部是已知的,协方差部分中的 C o v ( X , Y ) , C o v ( Y , X ) Cov(\mathcal X,\mathcal Y),Cov(\mathcal Y,\mathcal X) Cov(X,Y),Cov(Y,X)部分是未知的( Δ \Delta Δ表示)。当然,只要求解出一个,另一个自然也就求解出来(转置关系)。
为什么要加转置:
X , Y \mathcal X,\mathcal Y X,Y可能并不是‘相同大小’的随机变量集合,不加转置无法执行乘法运算。
矩阵的乘法分配律~
,因此有
E [ ϵ T ] = 0 \mathbb E[\epsilon^T] = 0 E[ϵT]=0是线性计算中的系数,是常数。
同理, C o v ( Y , X ) = ( Λ − 1 A T ) T = A ( Λ − 1 ) T Cov(\mathcal Y,\mathcal X) = \left(\Lambda^{-1}\mathcal A^T\right)^T = \mathcal A(\Lambda^{-1})^T Cov(Y,X)=(Λ−1AT)T=A(Λ−1)T。将 C o v ( X , Y ) , C o v ( Y , X ) Cov(\mathcal X,\mathcal Y),Cov(\mathcal Y,\mathcal X) Cov(X,Y),Cov(Y,X)带入,至此, Z \mathcal Z Z的概率分布完整表示如下:
Z ∼ N ( [ μ A ⋅ μ + B ] , [ Λ − 1 , Λ − 1 A T A Λ − 1 , L − 1 + A Λ − 1 A T ] ) \mathcal Z \sim \mathcal N\left(\begin{bmatrix}\mu \\ \mathcal A \cdot \mu + \mathcal B\end{bmatrix}, \begin{bmatrix}\Lambda^{-1},\Lambda^{-1}\mathcal A^T \\ \mathcal A\Lambda^{-1},\mathcal L^{-1} + \mathcal A \Lambda^{-1}\mathcal A^T\end{bmatrix}\right) Z∼N([μA⋅μ+B],[Λ−1,Λ−1ATAΛ−1,L−1+AΛ−1AT])
此时,关于 X , Y \mathcal X,\mathcal Y X,Y的联合概率分布已经求解,可以使用上一节的联合概率分布求解方式进行求解:
直接将结论抄过来啦~,有需要的去看一眼~,但是需要注意的是,由于上一节求解的是
P ( Y ∣ X ) \mathcal P(\mathcal Y \mid \mathcal X) P(Y∣X),本节求解的是
P ( X ∣ Y ) \mathcal P(\mathcal X \mid \mathcal Y) P(X∣Y),需要将所有的
a , b a,b a,b下标调换过来。
P ( X ∣ Y ) ∼ N ( μ a . b + Σ a b Σ b b − 1 X b , Σ a a . b ) = N ( μ a + Σ a b Σ b b − 1 ( X b − μ b ) , Σ a a − Σ a b Σ b b − 1 Σ b a ) \begin{aligned} \mathcal P(\mathcal X \mid \mathcal Y) & \sim \mathcal N(\mu_{a.b} + \Sigma_{ab}\Sigma_{bb}^{-1}\mathcal X_b,\Sigma_{aa.b}) \\ & = \mathcal N(\mu_a + \Sigma_{ab}\Sigma_{bb}^{-1}(\mathcal X_b - \mu_b),\Sigma_{aa} - \Sigma_{ab}\Sigma_{bb}^{-1}\Sigma_{ba}) \end{aligned} P(X∣Y)∼N(μa.b+ΣabΣbb−1Xb,Σaa.b)=N(μa+ΣabΣbb−1(Xb−μb),Σaa−ΣabΣbb−1Σba)
将上述对应的量代入:
Σ b a → \Sigma_{ba} \to Σba→正定矩阵的性质:正定矩阵的转置等于本身。
{ X b → Y μ a → E [ X ] = μ μ b → E [ Y ] = A μ + B Σ a a → Λ − 1 Σ b b → L − 1 + A Λ − 1 A T Σ a b → Λ − 1 A T Σ b a → A ( Λ − 1 ) T = A Λ − 1 \begin{cases} \mathcal X_b \to \mathcal Y\\ \mu_a \to \mathbb E[\mathcal X] = \mu \\ \mu_b \to \mathbb E[\mathcal Y] = \mathcal A \mu + \mathcal B \\ \Sigma_{aa} \to \Lambda^{-1} \\ \Sigma_{bb} \to \mathcal L^{-1} + \mathcal A \Lambda^{-1}\mathcal A^T \\ \Sigma_{ab} \to \Lambda^{-1}\mathcal A^T \\ \Sigma_{ba} \to \mathcal A(\Lambda^{-1})^T = \mathcal A\Lambda^{-1} \end{cases} ⎩⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎧Xb→Yμa→E[X]=μμb→E[Y]=Aμ+BΣaa→Λ−1Σbb→L−1+AΛ−1ATΣab→Λ−1ATΣba→A(Λ−1)T=AΛ−1
最终有:
P ( X ∣ Y ) ∼ N ( Σ { A T L ( y − B ) + A μ } , Σ ) Σ = Λ + A T L A − 1 \mathcal P(\mathcal X \mid \mathcal Y) \sim \mathcal N(\Sigma \{\mathcal A^T \mathcal L(y-\mathcal B) + \mathcal A \mu\},\Sigma) \quad \Sigma = \Lambda + \mathcal A^T \mathcal L\mathcal A^{-1} P(X∣Y)∼N(Σ{ATL(y−B)+Aμ},Σ)Σ=Λ+ATLA−1
至此,高斯分布部分介绍完毕。下一节将介绍高斯网络(Gaussian Network)
相关参考:
概率图模型(四):经典概率图模型
【PRML】高斯分布
机器学习-数学基础-概率-高斯分布6-已知边缘和条件概率求解联合概率分布