# Second moment conditional multivariate gaussian distribution

What is the second moment of the conditional distribution of one multivariate normal variable given another multivariate normal variable? I know the formula for the second central moment (the variance), but the second moment is hard to find online.

$$\int_{x=-\infty}^{x=\infty} xx'f(x\vert y)dx$$

In my case, the marginal and conditional means and variances are known.

• You know the conditional mean and variance, right?
– Dave
Apr 7 '21 at 12:08
• Yes indeed, and also the marginal mean and variance
– MD94
Apr 7 '21 at 12:14
• There is an equation relating mean, variance, and second moment. To jog your memory, you’ve probably seen it using expected value notation.
– Dave
Apr 7 '21 at 12:20
• You say it's a multivariate normal, but then integrate on the real line. Could you clarify? Apr 7 '21 at 12:34
• Yes, those formula's are indeed implied
– MD94
Apr 7 '21 at 12:57

For two multivariate normal vectors $$\mathbf{x}\sim\mathcal N(\mathbf{\mu_x},\Sigma_{\mathbf{x,x}})$$ and $$\mathbf{Y}\sim\mathcal N(\mathbf{\mu_Y},\Sigma_{\mathbf{Y,Y}})$$ we have that, given their covariance $$\Sigma_{\mathbf{x,Y}}$$:

$$E[\mathbf x|\mathbf Y]=\mathbf{\mu_x}+\Sigma_{\mathbf{x,Y}}\Sigma_{\mathbf{Y,Y}}^{-1}(\mathbf{Y-\mu_Y})$$

$$\text{Var}[\mathbf x|\mathbf Y]=\Sigma_{\mathbf{x,x}}-\Sigma_{\mathbf{x,Y}}\Sigma_{\mathbf{Y,Y}}^{-1}\Sigma_{\mathbf{Y,x}}$$

But the covariance is given in terms of the second moment:

$$\text{Var}[\mathbf x|\mathbf Y]=E[\mathbf {xx}^T|\mathbf Y]-E[\mathbf x|\mathbf Y]E[\mathbf {x}^T|\mathbf Y]$$

So

$$E[\mathbf {xx}^T|\mathbf Y] = \text{Var}[\mathbf x|\mathbf Y] + E[\mathbf x|\mathbf Y]E[\mathbf {x}^T|\mathbf Y]\\ =\Sigma_{\mathbf{x,x}}-\Sigma_{\mathbf{x,Y}}\Sigma_{\mathbf{Y,Y}}^{-1}\Sigma_{\mathbf{Y,x}}+ (\mathbf{\mu_x}+\Sigma_{\mathbf{x,Y}}\Sigma_{\mathbf{Y,Y}}^{-1}(\mathbf{Y-\mu_Y})) (\mathbf{\mu_x}+\Sigma_{\mathbf{x,Y}}\Sigma_{\mathbf{Y,Y}}^{-1}(\mathbf{Y-\mu_Y}))^T$$

I haven't checked, but it seems this all stems from the simple fact that:

$$\mathbf x=\mathbf{\mu_x}+\Sigma_{\mathbf{x,Y}}\Sigma_{\mathbf{Y,Y}}^{-1}(\mathbf{Y-\mu_Y})+\mathbf e\\ E[\mathbf {xx}^T|\mathbf Y]=(\mathbf{\mu_x}+\Sigma_{\mathbf{x,Y}}\Sigma_{\mathbf{Y,Y}}^{-1}(\mathbf{Y-\mu_Y}))(\mathbf{\mu_x}+\Sigma_{\mathbf{x,Y}}\Sigma_{\mathbf{Y,Y}}^{-1}(\mathbf{Y-\mu_Y}))^T+E[\mathbf {ee}^T|\mathbf Y]$$

So we could've started directly here, and then $$E[\mathbf {ee}^T|\mathbf Y] = \text{Var}[\mathbf x|\mathbf Y]$$.