Say there is a sequence of IID bernoulli trials $(x_1,x_2,...,x_N)$. Where $X \in \mathbb{R}^{N\times N}$ is a diagonal matrix with these RV's on the main diagonal and $\mathbb{P}\left[x_k =1\right]=p, \ 0<k\le N \in \mathbb{N}$. I want to know what is: $$ \mathbb{E}\left[ X\ W X \right], $$
where $W \in\mathbb{R}^{N\times N}\succ 0 $ is some positive definite weightings matrix. Due to this being bernoulli trials I believe the main diagonal after the expectation is excecuted to be $W_{ii} \cdot p$ and $W_{ij}\cdot p^2 $ for $i\neq j$. However, I am unsure.
You can explicitly give the elements of the product $X W X$ as, for element at coordinate $(i,j)$ \begin{align*} (X W X)_{ij} &= \sum_{k} X_{ik} (WX)_{kj}\\ &=\sum_{k} X_{ik} \sum_{\ell} W_{k\ell} X_{\ell j}\\ &=\sum_k \sum_\ell W_{k\ell} X_{ik}X_{\ell j} \end{align*}
The expectation is linear hence we only look at $\mathbb E[X_{ab} X_{cd}]$ which is $p$ if $(a,b)=(c,d)$ and $p^2$ otherwise.
Hence \begin{align*} \mathbb E[(XWX)_{ij}] &= \sum_k \sum_\ell W_{k\ell} [p\mathbb 1(i=\ell \land k=j) + p^2 (1-\mathbb 1(i=\ell \land k=j))]\\ &=\sum_k \sum_\ell W_{k\ell} [\mathbb 1(i=\ell \land k=j)(p-p^2) + p^2)]\\ &=p(1-p)W_{ij} + p^2 \sum_k \sum_\ell W_{k\ell} \end{align*}
Or in matrix notation $\mathbb E[XWX]=p(1-p)W + p^2 \mathbf 1 W \mathbf 1$ where in this case $\mathbf 1$ is the all one matrix.