Expected value of a random variable

Random variable $X$ has the probability density function \begin{equation*} f\left( x\right) =\left\{ \begin{array}{ccc} n\left( \frac{x}{\theta }\right) ^{n-1} & , & 0<x\leqslant \theta \\ n\left( \frac{1-x}{1-\theta }\right) ^{n-1} & , & \theta \leqslant x<1% \end{array}% \right. \end{equation*} show that if $k\in \mathbb{N}$ \begin{equation*} \mathrm{E}\left( X^{k}\right) =\frac{n\theta ^{k+1}}{n+k}+\sum% \limits_{i=0}^{k}\left( -1\right) ^{i}\binom{k}{k-i}\frac{n}{n+i}\left( 1-\theta \right) ^{i+1} \end{equation*}

It is easy to find the first term of $\mathrm{E}\left( X^{k}\right)$ but i couldn't find the second one. i think i have to use beta distribution properties. i tried to simulate the integral \begin{equation*} \int\nolimits_{\theta }^{1}nx^{k}\left( \frac{1-x}{1-\theta }\right) ^{n-1}% \mathrm{d}x \end{equation*} to beta pdf using $u=\frac{x-1}{\theta -1}$ transformation but i couldn't get a reasonable result. After this transformation is applied i have to find \begin{equation*} \int\nolimits_{0}^{1}u^{n-1}\left[ 1+u\left( \theta -1\right) \right] ^{k}% \mathrm{d}x \end{equation*} but i couldn't. Also I tried to use the equality \begin{equation*} x^{k}=1+\left( x-1\right) \sum\limits_{n=0}^{k-1}x^{n} \end{equation*} but i couldn't get the result.

\begin{align*} {\rm E}[X^k] &= \int_{x=0}^\theta x^k n \biggl(\frac{x}{\theta}\biggr)^{\!n-1} \, dx + \int_{x=\theta}^1 x^k n \biggl(\frac{1-x}{1-\theta}\biggr)^{\!n-1} \, dx \\ &= \frac{n}{\theta^{n-1}} \int_{x=0}^\theta x^{n+k-1} \, dx + \frac{n}{(1-\theta)^{n-1}} \int_{x=0}^{1-\theta} (1-x)^k x^{n-1} \, dx \\ &= \frac{n}{\theta^{n-1}} \cdot \frac{\theta^{n+k}}{n+k} + \frac{n}{(1-\theta)^{n-1}} \int_{x=0}^{1-\theta} \sum_{i=0}^{k} \binom{k}{i} (-x)^i x^{n-1} \, dx \\ &= \frac{n \theta^{k+1}}{n+k} + \frac{n}{(1-\theta)^{n-1}} \sum_{i=0}^{k} (-1)^i \binom{k}{k-i} \int_{x=0}^{1-\theta} x^{n+i-1} \, dx \\ &= \frac{n\theta^{k+1}}{n+k} + \frac{n}{(1-\theta)^{n-1}} \sum_{i=0}^k (-1)^i \binom{k}{k-i} \frac{(1-\theta)^{n+i}}{n+i} \\ &= \frac{n\theta^{k+1}}{n+k} + \sum_{i=0}^k (-1)^i \binom{k}{k-i} \frac{n}{n+i} (1-\theta)^{i+1}. \end{align*}
• (+1) The second integral is (by inspection) an incomplete Beta function: knowing this makes further analysis possible, makes many other formulas immediately accessible, and also leads to more efficient computation (when $k$ is medium to large). – whuber Apr 16 '14 at 15:08