Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am required to computed following Expectations : $E[\displaystyle\sum\limits_{i=1}^N \frac{X_{i}}{N}] = \bar{x}_{0}$ & $E[\displaystyle(\sum\limits_{i=1}^N \frac{X_{i}}{N})^2] = \frac{(N\bar{x}_{0}^2 + \sigma_{x}^2)}{N}$ with $ X_{i} \sim N(\bar{x}_{0},\sigma_{x}^2) \forall i = 1,2,\cdots,N$ & $X_{i} \bot X_{j} \forall i\not=j$ I'm looking to solve these expectation in symbolic as all these variable are unknown. Thanks for your help


share|improve this question
Looks more like a question for math.SE right now. Do you have a Mathematica angle here? – Yves Klett Jun 11 '14 at 20:54
Hi, sorry I've should have precised that I know the answer. This question is related to a larger system that require this computation to work – Alex Jun 11 '14 at 21:30
@Alex - If you know the answer: Why don't you just post it (preferably in Mathematica InputForm) ??? – eldo Jun 11 '14 at 21:58
@eldo I know how to calculate this expectation by hand but my goal is to have it done by Mathematica but I can't manage to make it work. I've tried meanH = Sum[Subscript[h, i], {i, 1, a}]/a; Expectation[meanH*meanH, Subscript[h, i] [Distributed] NormalDistribution[\!(TraditionalForm` *SubscriptBox[ OverscriptBox[(H), (_)], (0)]), Subscript[[Sigma], h]]]; out : Subscript[[Sigma], h]^2 + Subscript[OverBar[H], 0]^2 But this is not the right answer – Alex Jun 12 '14 at 1:54
@Alex Can you please clarify 3 aspects of your notation. FIRST, you have capital $N$ and lower case $n$ ... I presume that both of these should be the same $n$. SECOND, you specify that $X_i \sim N(\mu, \sigma)$. I presume you intend: $N(\mu, \sigma^2)$ i.e. the variance is $\sigma^2$. THIRD, you specify $i = 1, \dots,n$, but your sums run from 0 to $n$. Presumably you intend them to run from 1 to $n$. – wolfies Jun 12 '14 at 8:06
up vote 4 down vote accepted

This is a problem known as finding 'moments of moments'.

Notation Define the power sum $s_r$:

$$s_r=\sum _{i=1}^n X_i^r$$

Your problem only involves $s_1$.

The Problem

Let $\left(X_1,\ldots,X_n\right)$ denote a random sample of size $n$ from a population random variable $X$.

The problem is to find:

$$ E\Big [\Big (\frac1n\sum_{i=1}^n X_i\Big)^2\Big ] = E\Big [\big(\frac{s_1}{n}\big)^2\Big]$$

i.e. we seek the expectation of $\big(\frac{s_1}{n}\big)^2$ ... i.e. the 1st Raw Moment of $\big(\frac{s_1}{n}\big)^2$ ... so the solution (expressed ToCentral moments of the population) is:


  • RawMomentToCentral is a function from the mathStatica package for Mathematica,

  • $\acute{\mu}_1$ denote the 1st raw moment of random variable $X$ (i.e. the mean of $X$) and

  • $\mu_2$ denotes the 2nd central moment of random variable $X$ (i.e. the variance of $X$).

In your case, $X \sim N(\bar{x}_{0}, \sigma^2)$, so $\acute{\mu}_1 = \bar{x}_{0}$ and $\mu_2 = \sigma^2$. Substituting these values into Out[1]= yields: $$\frac{\sigma^2}{n} + \bar{x}_{0}^2 \quad \quad \text{(as required)}$$ All done.

More detail

There is an extensive discussion of moments of moments in Chapter 7 of our book:

  • Rose and Smith, "Mathematical Statistics with Mathematica", Springer, NY

A free download of the chapter is available here:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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