# Expectation of correlated variables

I wish to evaluate synbolically the correlation between two random variables $s_1,s_2$. They are defined by transforming four normal independent variables: $$s_1=(\eta_1+\rho\eta_2)^3+\alpha\eta_3\\ s_2=(\eta_1+\rho\eta_2)^3+\alpha\eta_4$$with $$\eta_i\sim \mathcal{N}(0,\sigma_i)\\ \rho,\alpha \in \mathbb{R}$$

For readability purposes, I wrote my code with many symbols. Thus, I post here a screenshot

The two evaluations shown here are indeed correct. However, if I try to compute the correlation $E[s_1,s_2]$ as following

Expectation[s1*s2,{s1\[Distributed]S1,s2\[Distributed]S2}]

it gets stuck evaluating it.

# EDIT

Strange fact, if I define directly the expectation $E[s_1,s_2]$ through the "base" random variables $\eta_i$, the evaluation does not fail.

Any explanation for the different behaviour, depending on the definition?

• Read this post mathematica.meta.stackexchange.com/q/1584/8822 if you want a better formatting for yuor post. – mattiav27 May 20 '17 at 9:48
• You have an error in your edit: you've switched $\eta_1$ and $\eta_2$ in the second term (or the error is in the original post). – JimB May 20 '17 at 15:18
• Your code doesn't seem consistent in that sometimes there are subscripts and sometimes not. Also when you use Expectation[s1*s2,{s1\[Distributed]S1,s2\[Distributed]S2}], the documentation states that you are assuming S1 and S2 are independent (which they are not). (This is not at all to say there aren't quirks when using TransformedDistribution.) – JimB May 20 '17 at 15:31
• $\text{Cov}(S_1,S_2) = 15 \left(\sigma _1^2 + \rho ^2 \sigma _2^2\right)^3$ – wolfies May 20 '17 at 17:42
• People here generally like users to post code as Mathematica code instead of images or TeX, so they can copy-paste it. It makes it convenient for them and more likely you will get someone to help you. You may find this this meta Q&A helpful – Michael E2 May 20 '17 at 19:16

It's not different behavior. When you use

Expectation[s1*s2,{s1\[Distributed]S1,s2\[Distributed]S2}]


the documentation states that you are assuming that s1 and s2 are independent (which they are not).

In addition you've previously defined s1 and s2 as "constants" in that Expectation doesn't know about $\eta1$, $\eta2$, $\eta3$, and $\eta4$ being random variables so you get the wrong answer even if s1 and s2 were independent:

(α η4 + (η2 + η1 ρ)^3) (α η3 + (η1 + η2 ρ)^3)


If s1 and s2 were independent you'd want $E(s1 * s2) = E(s1)*E(s2)$. You would want to use some previously undefined variables:

Expectation[x1 x2, {x1 \[Distributed] S1, x2 \[Distributed] S2}]


which gives you 0 in this case (and both means for S1 and S2 are zero).