# Expected value of $x^TMy$ for independent Gaussian vectors

Let $$x\sim \mathcal{N(\mu_x,\Sigma_x \succ 0)}$$ and $$y\sim \mathcal{N(\mu_y,\Sigma_y \succ 0)}$$ be multivariate Gaussian distributions, with $$\mu_x \in \mathbb{R}^n$$ and $$\mu_y \in \mathbb{R}^m$$ being the expected value vectors of $$x$$ and $$y$$ respectively. Let $$M\in \mathbb{R}^{n \times m}$$ be any matrix. Suppose that $$x$$ and $$y$$ are independent, that is $$\begin{bmatrix}x\\y\end{bmatrix}\sim \mathcal{N}\left(\begin{bmatrix}\mu_x\\\mu_y\end{bmatrix},\begin{bmatrix}\Sigma_x&0_{n \times m}\\0_{m \times n}&\Sigma_y \end{bmatrix}\right)\,.$$

What is the expression of $$\mathbb{E}(x^T M y)$$ in terms of $$\mu_x,\mu_y,\Sigma_x,\Sigma_y$$?

My guess would be $$\mathbb{E}(x^T M y)=\mu_x^T M \mu_y$$, but I'm confused how to prove this.

$$x$$ and $$y$$ are independent so $$x$$ and $$My$$ are independent. Therefore, $$\mathbb E[x^TMy]=\mathbb E[x^T]\mathbb E[My]=\mathbb E[x]^TM\mathbb E[y]=\mu_x^TM\mu_y.$$

$$x$$ and $$y$$ do not need to be Gaussian.

Consider the general case

$$\begin{bmatrix}x\\y\end{bmatrix}\sim \mathcal{N}\left(\begin{bmatrix}\mu_x\\\mu_y\end{bmatrix},\begin{bmatrix}\Sigma_{xx}&\Sigma_{xy}\\\Sigma_{yx}&\Sigma_{yy} \end{bmatrix}\right)\,.$$

Recall that the Cross-covariance_matrix between $$x$$ and $$y$$ is

$$\Sigma_{xy} = \Sigma_{yx}^T = \text{Cov}(x,y) = E[(x-\mu_x)(y-\mu_y)^T] = E[xy^T] - \mu_x \mu_y^T$$

Consequently $$E[yx^T] = \Sigma_{yx} + \mu_y\mu_x^T$$. Using the linearity of the expectated value and the trace trick we obtain

\begin{align} \def\tr{\operatorname{tr}} E[xMy^T] &= E[\tr(x^T M y)]\\ &=E[\tr(Myx^T)]\\ &= \tr(E[Myx^T])\\ &= \tr(ME[yx^T]) \\ &= \tr(M(\Sigma_{yx}+\mu_y\mu_x^T)) \\ &= \mu_x^T M\mu_y + \tr(M\Sigma_{yx}) \end{align}

In the special case when $$\Sigma_{yx}=0$$, the formula simplifies to $$E[xMy^T]=\mu_x^T M\mu_y$$