# Computing the expected value of a matrix?

This question is about finding a covariance matrix and I wasn't sure about the final step.

Given a standard $d$-dimensional normal RVec $X=(X_1,\ldots,X_d)$ has i.i.d components $X_j\sim N(0,1)$. Here we treat $X$ as a row vector. Now consider $Y:=\mu+XA$, where $\mu\in\mathbb{R}^m$, $A\in\mathbb{R}^{d\times m}$, so that $Y\in\mathbb{R}^m$. Then (we write the covariance matrix of Y as $C_Y^2$), $$C_Y^2=\mathbb{E}(Y-\mathbb{E}Y)^\intercal(Y-\mathbb{E}Y)=\mathbb{E}(XA)^\intercal XA$$ $$=\mathbb{E}A^\top X^\top XA=A^\top(\mathbb{E}X^\top X)A=A^\top IA=A^\top A.$$

I wasn't sure about how to compute $\mathbb{E}X^\top X$. Since $X$ is a row vector then $X^\top X$ is a column vector multiplied by a row vector which resulted in a matrix, then how can we take the expected value of a matrix? Moreover how can we get the identity matrix as the product?

Also how to choose dimension d and m, it is said (without reason) that it is not good if m>d.

May anyone explain it to me? Thanks.

You do it term by term, which you can do because Expectation is a linear operator. You get the identity matrix because the $X_i$ terms are independent and $N(0,1)$ so $E[X_i*X_i]=1$ but $E[X_i*X_j]=0.$