I'm trying with no luck to get Expectation
to calculate the expectation of expressions containing sums of products of independent random variables.
For instance, take $\mathbb{E}[\sum_{i=1}^n\sum_{j=1}^n X_iX_j]$, where $(X_1,\ldots,X_n)$ are mutually independent with $X_i \sim \mathcal{N}(a_i,b_i) $. Can Expectation
perform this calculation?
EDIT
Could get the expectation of a product right by using Piecewise
:
f[i_, j_] :=
Piecewise[{{Expectation[
x[i] x[j], {x[j] \[Distributed]
NormalDistribution[\[Mu][j], \[Sigma][j]],
x[i] \[Distributed] NormalDistribution[\[Mu][i], \[Sigma][i]]}],
i != j}, {Expectation[x[i]^2,
x[i] \[Distributed] NormalDistribution[\[Mu][i], \[Sigma][i]]],
i == j}}]
But still couldn't obtain $\sum_{i,j}f_{i,j}$.