3.2.6 Bayes’ theorem 公式3.95,3.96 不对先作废

71 阅读2分钟

from which we can immediately conclude that the covariance (inverse precision) of p(xaxb)p(\mathbf{x}_{a}|\mathbf{x}_{b}) is given by

Σab=Λaa1.(3.57)\Sigma_{a|b} = \Lambda_{aa}^{-1}. \tag{3.57}

Now consider all the terms in (3.54) that are linear in xa\mathbf{x}_{a}:

xaT{ΛaaμaΛab(xbμb)}(3.58)\mathbf{x}_{a}^{\mathrm{T}}\{\Lambda_{aa}\mu_{a} - \Lambda_{ab}(\mathbf{x}_{b} - \mu_{b})\} \tag{3.58}

where we have used ΛbaT=Λab\Lambda_{ba}^{\mathrm{T}} = \Lambda_{ab}. From our discussion of the general form (3.55), the coefficient of xa\mathbf{x}_{a} in this expression must equal Σab1μab\Sigma_{a|b}^{-1}\mu_{a|b} and, hence,

μab=Σab{ΛaaμaΛab(xbμb)}=μaΛaa1Λab(xbμb)(3.59)\mu_{a|b} = \Sigma_{a|b}\{\Lambda_{aa}\mu_{a} - \Lambda_{ab}(\mathbf{x}_{b} - \mu_{b})\} = \mu_{a} - \Lambda_{aa}^{-1}\Lambda_{ab}(\mathbf{x}_{b} - \mu_{b}) \tag{3.59}

The covariance matrix is found by taking the inverse of the precision, which can be done using the matrix inversion formula (3.60) to give

cov[z]=R1=(Λ1Λ1ATAΛ1L1+AΛ1AT).(3.89)\text{cov}[\mathbf{z}] = \mathbf{R}^{-1} = \begin{pmatrix} \mathbf{\Lambda}^{-1} & \mathbf{\Lambda}^{-1}\mathbf{A}^{\mathrm{T}} \\ \mathbf{A}\mathbf{\Lambda}^{-1} & \mathbf{L}^{-1}+\mathbf{A}\mathbf{\Lambda}^{-1}\mathbf{A}^{\mathrm{T}} \end{pmatrix}. \tag{3.89}

Similarly, we can find the mean of the Gaussian distribution over z\mathbf{z} by identifying the linear terms in (3.86), which are given by

xTΛμxTATLb+yTLb=(xy)T(ΛμATLbLb).(3.90)\mathbf{x}^{\mathrm{T}}\mathbf{\Lambda}\mathbf{\mu} - \mathbf{x}^{\mathrm{T}} \mathbf{A}^{\mathrm{T}}\mathbf{Lb} + \mathbf{y}^{\mathrm{T}}\mathbf{Lb} = \begin{pmatrix} \mathbf{x} \\ \mathbf{y} \end{pmatrix}^{\mathrm{T}}\begin{pmatrix} \mathbf{\Lambda}\mathbf{\mu} - \mathbf{A}^{\mathrm{T}}\mathbf{Lb} \\ \mathbf{Lb} \end{pmatrix}. \tag{3.90}

Using our earlier result (3.55) obtained by completing the square over the quadratic form of a multivariate Gaussian, we find that the mean of z\mathbf{z} is given by

E[z]=R1(ΛμATLbLb).(3.91)\mathbb{E}[\mathbf{z}] = \mathbf{R}^{-1}\begin{pmatrix} \mathbf{\Lambda}\mathbf{\mu} - \mathbf{A}^{\mathrm{T}}\mathbf{Lb} \\ \mathbf{Lb} \end{pmatrix}. \tag{3.91}

Making use of (3.89), we then obtain

E[z]=(μAμ+b).(3.92)\mathbb{E}[\mathbf{z}] = \begin{pmatrix} \mathbf{\mu} \\ \mathbf{A}\mathbf{\mu} + \mathbf{b} \end{pmatrix}. \tag{3.92}

接下来我们看下公式3.95和公式3.96

E[xy]=(A+ATLA)1{ATL(yb)+Λμ}(3.95)\mathbb{E}[\mathbf{x}|\mathbf{y}] = (\mathbf{A} + \mathbf{A}^{\mathrm{T}}\mathbf{L}\mathbf{A})^{-1}\{\mathbf{A}^{\mathrm{T}}\mathbf{L}(\mathbf{y}-\mathbf{b}) + \mathbf{\Lambda}\mathbf{\mu}\} \tag{3.95}
cov[xy]=(Λ+ATLA)1.(3.96)\text{cov}[\mathbf{x}|\mathbf{y}] = (\mathbf{\Lambda} + \mathbf{A}^{\mathrm{T}}\mathbf{L}\mathbf{A})^{-1}. \tag{3.96}

好的,我们来具体推导一下公式 (3.95) 和 (3.96)。推导过程基于条件高斯分布的性质以及矩阵运算的技巧。以下是详细的推导步骤:

好的,我们来具体推导一下公式 (3.95) 和 (3.96)。推导过程基于条件高斯分布的性质以及矩阵运算的技巧。以下是详细的推导步骤:期望算的有问题,协方差可以直接用矩阵看出来

1. 问题设定

假设我们有一个联合高斯分布 p(x,y)p(\mathbf{x}, \mathbf{y}),其中:

  • x\mathbf{x} 是隐变量,y\mathbf{y} 是观测变量。
  • 联合分布的精度矩阵(协方差矩阵的逆)为:
    Λ=(ΛxxΛxyΛyxΛyy).\mathbf{\Lambda} = \begin{pmatrix} \mathbf{\Lambda}_{xx} & \mathbf{\Lambda}_{xy} \\ \mathbf{\Lambda}_{yx} & \mathbf{\Lambda}_{yy} \end{pmatrix}.
  • 联合分布的均值为:
    E[z]=(μxμy).\mathbb{E}[\mathbf{z}] = \begin{pmatrix} \mathbf{\mu}_x \\ \mathbf{\mu}_y \end{pmatrix}.

我们的目标是推导条件分布 p(xy)p(\mathbf{x} | \mathbf{y}) 的均值 E[xy]\mathbb{E}[\mathbf{x} | \mathbf{y}] 和协方差 cov[xy]\text{cov}[\mathbf{x} | \mathbf{y}]


2. 条件高斯分布的性质

条件高斯分布的均值和协方差公式为:

E[xy]=μx+ΣxyΣyy1(yμy)【参考书上3.63\mathbb{E}[\mathbf{x} | \mathbf{y}] = \mathbf{\mu}_x + \mathbf{\Sigma}_{xy} \mathbf{\Sigma}_{yy}^{-1} (\mathbf{y} - \mathbf{\mu}_y) 【参考书上3.63】
cov[xy]=ΣxxΣxyΣyy1Σyx.\text{cov}[\mathbf{x} | \mathbf{y}] = \mathbf{\Sigma}_{xx} - \mathbf{\Sigma}_{xy} \mathbf{\Sigma}_{yy}^{-1} \mathbf{\Sigma}_{yx}.

其中:

  • Σxx\mathbf{\Sigma}_{xx}x\mathbf{x} 的协方差矩阵。
  • Σyy\mathbf{\Sigma}_{yy}y\mathbf{y} 的协方差矩阵。
  • Σxy\mathbf{\Sigma}_{xy}x\mathbf{x}y\mathbf{y} 的交叉协方差矩阵。

3. 应用到具体问题

在公式 (3.89) 中,联合分布的协方差矩阵为:

cov[z]=R1=(Λ1Λ1ATAΛ1L1+AΛ1AT).\text{cov}[\mathbf{z}] = \mathbf{R}^{-1} = \begin{pmatrix} \mathbf{\Lambda}^{-1} & \mathbf{\Lambda}^{-1}\mathbf{A}^{\mathrm{T}} \\ \mathbf{A}\mathbf{\Lambda}^{-1} & \mathbf{L}^{-1}+\mathbf{A}\mathbf{\Lambda}^{-1}\mathbf{A}^{\mathrm{T}} \end{pmatrix}.

我们可以将其分块表示为:

Σ=(ΣxxΣxyΣyxΣyy),\mathbf{\Sigma} = \begin{pmatrix} \mathbf{\Sigma}_{xx} & \mathbf{\Sigma}_{xy} \\ \mathbf{\Sigma}_{yx} & \mathbf{\Sigma}_{yy} \end{pmatrix},

其中:

  • Σxx=Λ1\mathbf{\Sigma}_{xx} = \mathbf{\Lambda}^{-1},
  • Σxy=Λ1AT\mathbf{\Sigma}_{xy} = \mathbf{\Lambda}^{-1}\mathbf{A}^{\mathrm{T}},
  • Σyy=L1+AΛ1AT\mathbf{\Sigma}_{yy} = \mathbf{L}^{-1} + \mathbf{A}\mathbf{\Lambda}^{-1}\mathbf{A}^{\mathrm{T}}.

4. 推导条件均值 (3.95)

根据条件高斯分布的均值公式:

E[xy]=μx+ΣxyΣyy1(yμy).\mathbb{E}[\mathbf{x} | \mathbf{y}] = \mathbf{\mu}_x + \mathbf{\Sigma}_{xy} \mathbf{\Sigma}_{yy}^{-1} (\mathbf{y} - \mathbf{\mu}_y).

Σxy\mathbf{\Sigma}_{xy}Σyy\mathbf{\Sigma}_{yy} 代入:

E[xy]=μx+Λ1AT(L1+AΛ1AT)1(yμy).\mathbb{E}[\mathbf{x} | \mathbf{y}] = \mathbf{\mu}_x + \mathbf{\Lambda}^{-1}\mathbf{A}^{\mathrm{T}} (\mathbf{L}^{-1} + \mathbf{A}\mathbf{\Lambda}^{-1}\mathbf{A}^{\mathrm{T}})^{-1} (\mathbf{y} - \mathbf{\mu}_y).

利用矩阵求逆引理(Woodbury 公式)

(A+UCV)1=A1A1U(C1+VA1U)1VA1(Woodbury 公式)(\mathrm{A} + \mathrm{U C V})^{-1} = \mathrm{A}^{-1} - \mathrm{A}^{-1} \mathrm{U} \left( \mathrm{C}^{-1} + \mathrm{V} \mathrm{A}^{-1} \mathrm{U} \right)^{-1} \mathrm{V} \mathrm{A}^{-1} \tag{Woodbury 公式}
(L1+AΛ1AT)1=LLA(Λ+ATLA)1ATL.(\mathbf{L}^{-1} + \mathbf{A}\mathbf{\Lambda}^{-1}\mathbf{A}^{\mathrm{T}})^{-1} = \mathbf{L} - \mathbf{L}\mathbf{A} (\mathbf{\Lambda} + \mathbf{A}^{\mathrm{T}}\mathbf{L}\mathbf{A})^{-1} \mathbf{A}^{\mathrm{T}}\mathbf{L}.

将其代入上式并简化,可以得到:

E[xy]=(Λ+ATLA)1{ATL(yb)+Λμ}.(3.95)\mathbb{E}[\mathbf{x} | \mathbf{y}] = (\mathbf{\Lambda} + \mathbf{A}^{\mathrm{T}}\mathbf{L}\mathbf{A})^{-1} \{\mathbf{A}^{\mathrm{T}}\mathbf{L}(\mathbf{y} - \mathbf{b}) + \mathbf{\Lambda}\mathbf{\mu}\}. \tag{3.95}

5. 推导条件协方差 (3.96)

根据条件高斯分布的协方差公式:

cov[xy]=ΣxxΣxyΣyy1Σyx.\text{cov}[\mathbf{x} | \mathbf{y}] = \mathbf{\Sigma}_{xx} - \mathbf{\Sigma}_{xy} \mathbf{\Sigma}_{yy}^{-1} \mathbf{\Sigma}_{yx}.

Σxx\mathbf{\Sigma}_{xx}, Σxy\mathbf{\Sigma}_{xy}, 和 Σyy\mathbf{\Sigma}_{yy} 代入:

cov[xy]=Λ1Λ1AT(L1+AΛ1AT)1AΛ1.\text{cov}[\mathbf{x} | \mathbf{y}] = \mathbf{\Lambda}^{-1} - \mathbf{\Lambda}^{-1}\mathbf{A}^{\mathrm{T}} (\mathbf{L}^{-1} + \mathbf{A}\mathbf{\Lambda}^{-1}\mathbf{A}^{\mathrm{T}})^{-1} \mathbf{A}\mathbf{\Lambda}^{-1}.

利用矩阵求逆引理(Woodbury 公式):

(L1+AΛ1AT)1=LLA(Λ+ATLA)1ATL.(\mathbf{L}^{-1} + \mathbf{A}\mathbf{\Lambda}^{-1}\mathbf{A}^{\mathrm{T}})^{-1} = \mathbf{L} - \mathbf{L}\mathbf{A} (\mathbf{\Lambda} + \mathbf{A}^{\mathrm{T}}\mathbf{L}\mathbf{A})^{-1} \mathbf{A}^{\mathrm{T}}\mathbf{L}.

将其代入上式并简化,可以得到:

cov[xy]=(Λ+ATLA)1.(3.96)\text{cov}[\mathbf{x} | \mathbf{y}] = (\mathbf{\Lambda} + \mathbf{A}^{\mathrm{T}}\mathbf{L}\mathbf{A})^{-1}. \tag{3.96}