# Find the expected value of $(\bar X_n-p)^3$

Let $X_1,X_2,\dots, X_n$ be a random sample from a Bernoulli distribution with parameter $p$. Let $\bar X_n$ be the sample average given by $\bar X_n=\frac{1}{n} (X_1+X_2+\dots+ X_n)$). Find the expected value of $(\bar X_n-p)^3$.

Trial: I know $\sum_{i=1}^n \sim \text{Bin}(n,p)$ but then how I calculate the given calculation. Please help.

Let $S$ denote $X_1+X_2+\cdots+X_n$. Then, \begin{align} E[(\bar{X}_n-p)^3] &= E\left[\left(\frac{1}{n}S-p\right)^3\right]\\ &= \frac{1}{n^3}E[S^3]-3p\frac{1}{n^2}E[S^2]+3p^2\frac{1}{n}E[S]-p^3 \end{align} where you should be able to find the value of $E[S]$ and $E[S^2]=\operatorname{var}(S)+(E[S])^2$ since you know that $S$ is a Binomial$(n,p)$ random variable. Evaluating $E[S^3]$ is a little trickier. One approach is to multiply out the cubic to get terms such as $E[X_iX_jX_k]$, $E[X_i^2X_j]$, and $E[X_i^3]$ and use independence and the fact that for Bernoulli random variables, $X_i^m = X_i$ and so $E[X_i^m]=E[X_i]=p$. Alternatively, find $E[S(S-1)(S-2)]$ directly from the binomial distribution (same trick as is sometimes used in computing the variance of $S$ using $\operatorname{var}(S) = E[S(S-1)] + E[S] - (E[S])^2$) and find $E[S^3]$ from that.
This is probably not the way most people would solve this, but I like it because it is completely general, not distribution specific, and basically a one-liner. In particular, if $s_1$ denotes the sample sum, then you seek $E[(\frac {s_1}{n} - p)^3]$, which is just the 1st Raw Moment of $(\frac {s_1}{n} - p)^3$:
where RawMomentToRaw is a mathStatica function, and the $\mu_i$'s denote the raw moments of whatever distribution you happen to be working with (provided, of course, they exist). In the case of the Bernoulli, it happens that all the positive raw moments are $p$, so it simplifies to: