# evaluating expectation of $\mathbb{E}[f(x)f(x)^T]$

I am trying to evaluate $$E[f(x)f(x)^T]$$ where $$f(x) = Nx$$ and $$N \in \mathbb{R}^{N \times N}$$, and also $$p(x) = \mathbb{N} (x|μ, \sigma)$$

So, as we know,

\begin{align*} E[f(x)f(x)^T] &= \int_{-\infty}^{\infty} f(x)f(x)^{T} p(x)dx \\ &= \int_{-\infty}^{\infty} Nx(Nx)^{T} p(x) dx \\ &= \int_{-\infty}^{\infty} Nxx^{T}N^{T} p(x) dx \end{align*}

Now, I am confused about the next step as I haven't evaluated $$\mathbb{E}$$ with a matrix before. Can I drag the $$NN^T$$ part outside as it's constant with respect to $$x$$? Can I break the order? What to do next?

Assuming the matrix doesn't depend on the random vector $$x$$, you can indeed take the matrix outside the expectation, since matrix multiplication is a linear operation. You just have to be careful to remember that matrix multiplication is "order dependent" i.e. not commutative:

$$\mathbb{E}[(Nx)(Nx)^T] = \mathbb{E}[Nxx^T N^T] = N\mathbb{E}[xx^T]N^T = NC N^T$$ where $$C = \mathbb{E}[xx^T]$$.

Hope that helps!

• Thanks, it certainly helps. I want to ask what if I have $E[(Nx)^{T}(Nx)]$ instead? Then the order would be $x^{T}N^{T}Nx$. Then how would I approach? Nov 10, 2020 at 21:21
• Well, you're looking for the expected norm of the (transformed) vector $Nx$; the expected norm is the trace of the correlation matrix (see here). So, using what you learned about how the correlation matrix transforms, I think you can probably figure it out - it'll be the trace of $NCN^T$. Nov 10, 2020 at 21:44

Yes, you can pull out the $$N$$. Doing so leaves you with $$N \left( \int_{-\infty}^\infty xx^T\,p(x)\,dx\right)N^T = N \,\mathbb{E}(xx^T)N^T.$$ One way to proceed is to note that $$\mathbb{E}(xx^T) - \mathbb{E}(x)\mathbb E(x)^T$$ is the covariance matrix of $$x$$.

• Thanks. Yeah, I know I can write, $E[xx^{T}] = Var(x) + \mu\mu^{T}$. I was basically confused about the order. Now, what happens if I have $x^{T}N^{T}Nx$. I was actually trying to understand the ordering here. Or should I ask a new question? Nov 10, 2020 at 21:14
• @AhsanulHaque You could if you want. The quick answer is that the expectation of $x^TN^TNx$ is a scalar rather than a matrix, and there is no longer an obvious way to factor out the $N$'s in the computation. However, it turns out that the expectation of $x^TN^TNx$ is simply the trace of the (matrix-valued) expectation of $Nxx^TN^T$. Nov 10, 2020 at 21:44