# Assign a Distribution to a group of symbolic variable [closed]

I'm looking to compute this Expectation :

"i" represent a individual and h(i) is value. I would like the compute the Expected value of his value times the mean of the groups. Everything is unknown so symbolic is conserved.

Any help would be greatly appreciated

Thank

Alexandre

-

## closed as unclear what you're asking by ciao, Öskå, m_goldberg, Jens, RunnyKineJun 11 '14 at 1:58

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

I can not see the image well. it is too small. can you zoom it up or may be post actual Mathematica code? –  Nasser Jun 10 '14 at 3:50
You have Expectation[h[1]... but do you perhaps mean Expectation[Sum[h[i]...? –  Sjoerd C. de Vries Jun 10 '14 at 5:41
@Nasser: Right click --> Open graphic in new card, yielding this. –  jojek Jun 10 '14 at 8:27

Some problems are better suited to doing partly by hand, or at least progressing them into a form that a computer algebra system can then assist with ...

The problem

Let $X \sim N(\mu, \sigma^2)$, and let $(X_1, \dots, X_n)$ denote an iid random sample of size $n$ drawn on $X$. We seek:

\begin{align*}\displaystyle E\Big[X_1 \frac{\sum_{i=1}^n X_i}{n} \Big] &= \frac1n E\Big[ X_1^2 + X_1X_2 + X_1X_3 + \dots + X_1X_n \Big] \\ & = \frac1n E\Big[ X_1^2 \Big] + \frac{n-1}{n} E\Big[ X_1 X_{j\neq1} \Big] \end{align*}

• The first term: Since $Var[X] = E[X^2]- \mu^2$, we immediately have: $E[ X_1^2] = \mu^2 + \sigma^2$ , or do it in Mathematica:

Expectation[x^2 , {x \[Distributed] NormalDistribution[\[Mu], \[Sigma]]}]

• The second term: By independence, $E\Big[ X_1 X_{j\neq1} \Big] = E[X_1] E[ X_{j\neq1}] =\mu^2$, or do it in Mathematica:

Expectation[ x y , {x \[Distributed] NormalDistribution[\[Mu], \[Sigma]], y \[Distributed] NormalDistribution[\[Mu], \[Sigma]] }]

In summary:

$$E\Big[X_1 \frac{\sum_{i=1}^n X_i}{n} \Big] = \mu^2 + \frac{\sigma^2}{n}$$

To be frank, there is little value added by using a computer algebra system for this problem.

-
Hi, Thanks for for answer I totaly agree with you. Unfortunately the problem I presented is only the first step of a larger recursif system that requires at the second step to compute Expectation(X[j]^2) (read j as j=1:n j not= i) –  Alex Jun 10 '14 at 19:47
@user13406 Calculating expectations such as $E[(\sum_{i=1}^n X_i)^2]$ etc can be solved with a computer algebra system ... (if that is your problem, please post it {using math notation, not Mathematica notation}). The difficulty with automation occurs when you mix a specific variable say $X_2$ and an index variable say $X_i$, as in $E[X_2 \sum_{i=1}^n X_i^2]$, because one has to break out the $X_2$ variable from the rest, and treat it differently ... which is essentially a manual process. –  wolfies Jun 10 '14 at 19:55
Yes this would be what I'm looking for. I would like to be able to compute $E[\displaystyle\sum\limits_{i=0}^n X_{i}]$ but also $E[\displaystyle\sum\limits_{i=0}^n X_{i}^2]$ is it possible with Mathematica? –  Alex Jun 10 '14 at 20:42
@Alex Well, those two cases are easy, since $E\big[ \sum_{i=1}^n X_i\big] = n E[X]$, and $E\big[ \sum_{i=1}^n X_i^2\big] = n E[X^2]$ ... but if you have a more tricky problem, like $E\big[ (\sum_{i=1}^n X_i)^2\big]$, then please post that as a separate question. –  wolfies Jun 11 '14 at 7:42
Alright thanks mathematica.stackexchange.com/questions/50606/… –  Alex Jun 12 '14 at 1:58