Expectation of the product of two matrices I recently viewed this question and I decided it to give it a try. I got stuck in the computation of a certain expectation and variance. Summarizing the problem, this is the issue:

Let $X\in R^{n\times d}$ be a data matrix, $R\in R^{n\times d}$ a
matrix such that $ R_{ij}\sim\text{Bern}(p)$ is sampled i.i.d. from
the Bernoulli distribution, $M=X\odot R$ the element-wise product
of the previous two matrices, and $\Gamma$ be a diagonal matrix with
$\Gamma_{ii}=(X^\top X)_{ii}^{1/2}$.
Show that $E[M]=pX$, and $var(M)=p(1-p)\Gamma²$

I first went considering both the columns of $X$ and $R$ as independent vectors. Using a specific example where both $X$ and $R$ have three columns, i.e. $X=[A\ B\ C]^T$, and $R=[\alpha\ \beta\ \delta]^T$, we have that $M=[\alpha A\ \beta B\ \delta C]^T$. Taking the expectation of this:
$$E[M]=
\begin{bmatrix} 
E[\alpha A] \\
E[\beta B]\\
E[\delta C] \\
\end{bmatrix} \stackrel{\star}{=} 
\begin{bmatrix} 
E[\alpha]E[A] \\
E[\beta]E[B]\\
E[\delta]E[C] \\
\end{bmatrix} =
\begin{bmatrix} 
pE[A] \\
pE[B]\\
pE[C] \\
\end{bmatrix}=pE[X]
$$
where I used that $\star$ the variables are independent.
It doesn't look like the answer is correct and I am not sure what I am misunderstanding. For the variance, I don't even know where to start.

I just realised what is the answer (and also thanks to the reflection questions of @Gateau-Gallois).

*

*Mean: $X$ is taken as a matrix of constants whereas $R\sim Bern(p)$. That's why $E[M]=pX$.


*Variance: Following a similar argument, one can see then that the covariance matrix is:
$$
\begin{align}
var(M_{ij})&=var(X_{ij}R_{ij})\stackrel{\star}{=}X_{ij}^2var(R_{ij})
\end{align}$$
where $\star$ is the same assumption as in the question and the fact that $var(aX)=a^2var(X)$. The expression results in 0 if $i\neq j$ since $R_{ij}$ are i.i.d. and otherwise is $X^2_{ii}var(R_{ii})=X^2_{ii}p(1-p)$. Taking, then, the matrix form:
$$
\begin{align}
var(M)=p(1-p)(X^TX)_{ii}\stackrel{\star^2}{=}p(1-p)\Gamma^2
\end{align}
$$
where $\star^2$ is the definition $\Gamma=(X^TX)_{ii}^{1/2}$stated in the question.
