# Conditional distribution of multivariate normal distribution

I'm doing some self studying this, I got stuck on this question:

Suppose $$(X,Y,Z)'$$ is normal with density $$\begin{equation*} \begin{split} C\cdot \text{exp}\{-\frac{1}{2}(4x^{2}+3y^{2}+5z^{2}+2xy+6xz+4zy)\}, \end{split} \end{equation*}$$ where $$C$$ is a normalizing constant. Determine the conditional distribution of $$X$$ given that $$X+Z=1$$ and $$Y+Z$$=0.

This is what I tried:

$$\begin{equation*} \begin{split} \mathbf{\mu}=\left[\begin{array}{c} 0 \\ 0\\ 0 \end{array}\right]\qquad \Lambda^{-1}=\left[\begin{array}{ccc} 4& 1& 3 \\ 1& 3& 2\\ 3& 2& 5 \end{array}\right],\qquad \\ \begin{array}{c} U=X \\ V=X+Z \\ W=Y+Z \end{array} \\ \mathbf{B}=\left[\begin{array}{c} U \\ V\\ W \end{array}\right]=\left[\begin{array}{ccc} 1 & 0& 0 \\ 1 & 0& 1\\ 0& 1& 1 \end{array}\right] \end{split} \end{equation*}$$ $$\begin{equation*} \begin{split} \mathbf{B\mu}=\left[\begin{array}{ccc} 1 & 0& 0 \\ 1 & 0& 1\\ 0& 1& 1 \end{array}\right]\left[\begin{array}{c} 0 \\ 0\\ 0 \end{array}\right] =\left[\begin{array}{c} 0 \\ 0\\ 0 \end{array}\right] \end{split} \end{equation*}$$ $$\begin{equation*} \begin{split} \Lambda=\frac{1}{|\mathrm{det} \Lambda^{-1}|} \left[\begin{array}{ccc} \mathrm{det} \left|\begin{array}{cc} 3 &2 \\ 2 &5 \end{array}\right|=11 &\mathrm{det}\left|\begin{array}{cc} 1 &2 \\ 3 &5 \end{array}\right|=(-1)& \mathrm{det}\left|\begin{array}{cc} 1 &3 \\ 3 &2 \end{array}\right|=(-7) \\ \mathrm{det}\left|\begin{array}{cc} 1 &3 \\ 2 &5 \end{array}\right|=(-1) & \mathrm{det}\left|\begin{array}{cc} 4 &3 \\ 3 &5 \end{array}\right|=11 &\mathrm{det}\left|\begin{array}{cc} 4 &1 \\ 3 &2 \end{array}\right|=5 \\ \mathrm{det}\left|\begin{array}{cc} 1 &3 \\ 3 &2 \end{array}\right|=(-7) & \mathrm{det}\left|\begin{array}{cc} 4&3 \\ 1 &2 \end{array}\right|=5 & \mathrm{det}\left|\begin{array}{cc} 4 &1 \\ 1 &3 \end{array}\right|=11 \end{array}\right]\\ \frac{1}{|\mathrm{det}\Lambda^{-1}|}=4\cdot 3\cdot 5-1\cdot 1\cdot 5-2\cdot 2\cdot 4-3\cdot 3\cdot 3+1\cdot 2\cdot 3+1\cdot 2\cdot 3\\ =60-5-16-27+6+6=24\\ \Lambda=\frac{1}{24}\left[\begin{array}{ccc} 11 & (-1) & (-7) \\ (-1) & 11 & 5\\ (-7) & 5 & 11 \end{array}\right] \end{split} \end{equation*}$$ $$\begin{equation*} \begin{split} \mathbf{B \Lambda}=\frac{1}{24}\left[\begin{array}{ccc} 1 & 0& 0 \\ 1 & 0& 1\\ 0& 1& 1 \end{array}\right]\left[\begin{array}{ccc} 11 & (-1) & (-7) \\ (-1) & 11 & 5\\ (-7) & 5 & 11 \end{array}\right]\\ =\frac{1}{24}\left[\begin{array}{ccc} 1\cdot 11+0\cdot (-1)+0\cdot (-7) & 1\cdot (-1)+0\cdot 11+0\cdot 5& 1\cdot (-7)+0\cdot 5+0\cdot 11 \\ 1\cdot 11+0\cdot (-1)+1\cdot (-7) & 1\cdot (-1)+0\cdot 11+1\cdot 5& 1\cdot (-7)+0\cdot 5+1\cdot 11\\ 0\cdot 11+1\cdot (-1)+1\cdot (-7) & 0\cdot (-1)+1\cdot 11+1\cdot 5 &0\cdot (-7)+1\cdot 5+1\cdot 11 \end{array}\right]\\ =\frac{1}{24}\left[\begin{array}{ccc} 11 & (-1) & (-7) \\ 4 & 4 & 4\\ (-8) & 16 & 16 \end{array}\right] \end{split} \end{equation*}$$ $$\begin{equation*} \begin{split} \mathbf{B\Lambda B^{T}}=\frac{1}{24}\left[\begin{array}{ccc} 11 & (-1) & (-7) \\ 4 & 4 & 4\\ (-8) & 16 & 16 \end{array}\right]\left[\begin{array}{ccc} 1 & 1&0 \\ 0 &0 &1\\ 0& 1&1 \end{array}\right]\\ =\frac{1}{24}\left[\begin{array}{ccc} 11\cdot 1+(-1)\cdot 0+(-7)\cdot 0 & 11\cdot 1+(-1)\cdot 0+(-7)\cdot 1& 11\cdot 0+(-1)\cdot 1+(-7)\cdot 1 \\ 4\cdot 1+4\cdot 0+4\cdot 0 & 4\cdot 1+4\cdot 0+4\cdot 1& 4\cdot 0+4\cdot 1+4\cdot 1\\ (-8)\cdot 1+16\cdot 0+16\cdot 0& (-8)\cdot 1+16\cdot 0+16\cdot 1& (-8)\cdot 0+16\cdot 1+16\cdot 1 \end{array}\right]\\ =\frac{1}{24}\left[\begin{array}{ccc} 11 & 4& (-8) \\ 4 & 8& 8\\ (-8)& 8& 32 \end{array}\right] \end{split} \end{equation*}$$ $$\begin{equation*} \begin{split} \mathrm{E}(U|V=0,W=1)=\mu_{x}+\Sigma_{12}\Sigma_{22}^{-1}\left[\begin{array}{c} 1-\mu_{v}\\ 0-\mu_{w} \end{array}\right]\\ \Sigma_{12}=\left[\begin{array}{cc} 4&(-8) \end{array}\right]\\ \Sigma_{21}=\left[\begin{array}{c} 4 \\ (-8) \end{array}\right]\\ \Sigma_{22}=\left[\begin{array}{cc} 8 & 8 \\ 8 & 32 \end{array}\right] \end{split} \end{equation*}$$ $$\begin{equation*} \begin{split} \Sigma_{22}^{-1}=\frac{1}{8\cdot 32-8\cdot 8}\left[\begin{array}{cc} 32 & -8 \\ -8 & 8 \end{array}\right]=\frac{1}{3\cdot 8\cdot 8}\left[\begin{array}{cc} 32 & -8 \\ -8 & 8 \end{array}\right] \end{split} \end{equation*}$$ $$\begin{equation*} \begin{split} \mathrm{E}(U|V=1,W=0)=0+\frac{1}{3\cdot 8\cdot 8}\left[\begin{array}{cc} 4&(-8) \end{array}\right]\left[\begin{array}{cc} 32 & -8 \\ -8 & 8 \end{array}\right]\left[\begin{array}{c} 1-\mu_{v}\\ 0-\mu_{w} \end{array}\right]\\ =\frac{1}{3\cdot 8\cdot 8}\left[\begin{array}{cc} 4\cdot 32+(-8)\cdot (-8) & 4\cdot (-8)+(-8)\cdot 8 \end{array}\right]\left[\begin{array}{c} 1-\mu_{v}\\ 0-\mu_{w} \end{array}\right]\\ =\frac{1}{3\cdot 8\cdot 8}\left[\begin{array}{cc} 192 &(-96) \end{array}\right]\left[\begin{array}{c} 1-0\\ 0-0 \end{array}\right]\\ =\frac{1}{192}\left[\begin{array}{cc} 192\cdot 1 + (-96)\cdot 0 \end{array}\right]=1 \end{split} \end{equation*}$$ $$\begin{equation*} \begin{split} 24\cdot \mathrm{Var}(U|V=1,W=0)=\Sigma_{11}-\Sigma_{12}\Sigma_{22}^{-1}\Sigma_{21}=11-\frac{1}{192}\left[\begin{array}{cc} 192 + (-96) \end{array}\right]\left[\begin{array}{c} 4 \\ (-8) \end{array}\right]\\ =11-\frac{1}{192}\left[\begin{array}{c} 192\cdot 4+(-96)\cdot (-8) \end{array}\right]\\ =11-\frac{1}{192}\left[\begin{array}{c} 1536 \end{array}\right]=11-8=3\\ \mathrm{Var}(U|V=1,W=0)=\frac{3}{24}=\frac{1}{8} \end{split} \end{equation*}$$ $$\begin{equation*} \begin{split} X|X+Y=1,Y+Z=0\in N(1,\frac{1}{8}) \end{split} \end{equation*}$$

Is this correct? My book gives me a different answer.

It looks like you're on the right track, but you're working way too hard on this one. Sooner or later algebraic and numerical mistakes will creep into even the best calculations. A good strategy is to minimize the amount calculation: the Principle of Mathematical Laziness. A key element of this principle is just-in-time computation: don't do any work until you have to. The following solution illustrates these ideas.

You have seen the virtue of changing variables. Keeping $$X$$ (whose conditional distribution we wish to compute), let the two new variables be

$$U = Y+Z,\ V = X+Z.$$

Consequently, looking ahead to the next step, note that the original variables can be expressed as

$$Y = U-V+X,\ Z=V-X.$$

You also recognized the need to compute the Jacobian of this transformation. Using the method I have described at https://stats.stackexchange.com/a/154298/919 this is almost trivial:

$$\left|\mathrm{d}x\,\mathrm{d}y\,\mathrm{d}z\right| = \left|\mathrm{d}x\wedge \mathrm{d}(u-v+x)\wedge \mathrm{d}(v-x)\right| = \left|\mathrm{d}x\, \mathrm{d}u\, \mathrm{d}v\right|.$$

This leaves only the argument of the exponential, into which we need to substitute

$$y = u-v+x,\ z = v-x$$

and then set $$u=0$$ and $$v=1.$$ Focusing on the argument of the exponential (and ignoring the necessary division by $$2$$), this can be performed by visual inspection of the coefficients of $$x$$ and $$x^2$$ and then, as always with Normal distributions, completing the square:

\begin{aligned} 4x^{2}&+3y^{2}+5z^{2}+2xy+6xz+4zy\\ &= 4x^2 + 3(u-v+x)^2 + \cdots + 4(v-x)(u-v+x)\\ &= (4+3+5+2-6-4)x^2 \\&+ (0-6-10-2+6+8)x \\&+ \text{constants}\\ &= 4x^2 - 4x + \text{constants} \\ &= \frac{(x-1/2)^2}{(1/2)^2}+\text{some constant}. \end{aligned}

We know the conditional distribution will be Normal with some mean $$\mu$$ and some standard deviation $$\sigma$$, which means this quadratic part will take the form $$(x-\mu)^2/\sigma^2$$ plus some constant. Comparing with the foregoing, you can read off the values $$\mu=1/2$$ and $$\sigma=1/2.$$

You will, of course, wish to check this work: but I hope you find this to be much less effort than checking your original calculations.