2
$\begingroup$

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}$.

$\endgroup$
1
  • $\begingroup$ Depending on what kind of sums you have you might consider the following related post: mathematica.stackexchange.com/questions/50606/…. Maybe one or more additional examples help us give you a more general approach. $\endgroup$
    – JimB
    Commented Jul 2, 2020 at 3:02

2 Answers 2

4
$\begingroup$

I'm pretty sure this doesn't answer the question the way you want (and I would want also) but using Expectation works if you specify n:

n = 5;
Expectation[Sum[x[i] x[j], {i, n}, {j, n}], 
  Table[x[i] \[Distributed] NormalDistribution[μ[i], σ[i]], {i, n}]] // FullSimplify
(* (μ[1] + μ[2] + μ[3] + μ[4] + μ[5])^2 + σ[1]^2 + σ[2]^2 + σ[3]^2 + σ[4]^2 + σ[5]^2 *)

From that results one can see the general form:

n =.;
Sum[\[Mu][i], {i, n}]^2 + Sum[\[Sigma][i]^2, {i, n}]

General form

$\endgroup$
1
  • $\begingroup$ I've managed to get the expectation of the product, but still couldn't obtain the sum. If that is Maybe that is as far as we can get without having recourse to your inductive approach $\endgroup$
    – Ararat
    Commented Jul 3, 2020 at 0:04
1
$\begingroup$

Same setup as in the answer by @JimB (fixed n) - just for fun.

 proc = ItoProcess[{
   \[DifferentialD]x1[t] == \[Sigma]1 \[DifferentialD]w1[t], 
   \[DifferentialD]x2[t] == \[Sigma]2 \[DifferentialD]w2[t], 
   \[DifferentialD]x3[t] == \[Sigma]3 \[DifferentialD]w3[t]}, 
    (x1[t] + x2[t] + x3[t])^2, {{x1, x2, x3}, {\[Mu]1, \[Mu]2, \[Mu]3}}, {t, 0}, 
    {w1 \[Distributed] WienerProcess[], 
     w2 \[Distributed] WienerProcess[],
     w3 \[Distributed] WienerProcess[]}];

Mean[proc[1]]
(* (\[Mu]1+\[Mu]2+\[Mu]3)^2+\[Sigma]1^2+\[Sigma]2^2+\[Sigma]3^2 *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.