Expectation of positive semidefinite random matrix Let $X$ be a random square symmetric matrix. Assume $X$ is positive semidefinite almost surely. Also assume that the expectation $E[X]$ exists. Does it follow that $E[X]$ is positive semidefinite?
All my intuition tells me that this must be true but a rigorous proof eludes me.
 A: If $X$ is positive semidefinite almost surely, then for any vector $\mathbf u$, we have ${\mathbf u}^{\mathsf T} X \mathbf u \ge 0$ almost surely. This means that $\mathbb E[{\mathbf u}^{\mathsf T} X \mathbf u] \ge 0$, and by linearity of expectation ${\mathbf u}^{\mathsf T} \mathbb E[X] \mathbf u \ge 0$. (The expression ${\mathbf u}^{\mathsf T} X \mathbf u$ may not be linear in $\mathbf u$ for a fixed $X$, but it's certainly linear in $X$ for a fixed $\mathbf u$.)
Since this holds for any $\mathbf u$, that means $\mathbb E[X]$ is positive semidefinite.
A: I think the answer is yes. Suppose the probability space is $(\Omega,\mathcal{F},P)$, where $P$ is the probability measure associated with $X$, and denote the dimension of $X$ is $n$, i.e., $X\in R^{n\times n}$. Also we denote $M\geq 0$ if $M$ is positive semidefinite. We will prove it by two steps.
For the first step, by the linear property of expectation, we get
$$\mathbb{E}f_{\omega}(v) =  \mathbb{E}(v^TXv) = v^T(\mathbb{E}X) v$$
for any $v\in R^n$. 
Now is the second step. $X$ is positive semidefinite almost surely $\Rightarrow$ $\exists A\subset \Omega$, s.t. $P(A) = 1$ and $\forall \omega \in A$, $X(\omega)\geq 0$.
Then fix an $\omega\in A$, by the definition of positive semidefinite we know that $\forall v\in R^n$, we have $f_{\omega}(v) = v^TX(\omega)v\geq0$ (we define $f_{\omega}(v) = v^TX(\omega)v$). Then (sometimes we omit $\omega$ and write $X(\omega)$ as $X$) 
$$\mathbb{E}f_{\omega}(v) = \int_{\Omega} v^TXv\ {\rm d}P = \int_{A} v^TXv\ {\rm d}P+ \int_{\Omega\setminus A} v^TXv\ {\rm d}P.$$
Since $P(\Omega\setminus A) = 1-P(A) = 0$, we have $\int_{\Omega\setminus A} v^TXv\ {\rm d}P=0$. Thus what we get is
$$\mathbb{E}f_{\omega}(v) = \mathbb{E} (v^TXv)=\int_{A} v^TXv\ {\rm d}P\geq 0,$$
since $f_{\omega}(v) = v^TX(\omega)v\geq 0$ for $\omega\in A$. In words, we get $\mathbb{E}(v^TXv)\geq 0$, $\forall v\in R^n$.
Now combine two results together, we get
$$v^T(\mathbb{E}X) v = \mathbb{E}(v^TXv)\geq 0,\ \forall v\in R^n,$$
which implies that $\mathbb{E}X$ is positive semidefinite.

To summarize, we just showed that


*

*$v^T(\mathbb{E}X) v = \mathbb{E}(v^TXv)$. This is trivial.

*$\mathbb{E}(v^TXv)\geq 0,\ \forall v\in R^n$. This is where the condition "$X\geq 0$ almost surely" is used.
