# Discrepancy in expectation calculation

Suppose we have a random sample $(X_1,..,X_n)$ from a Uniform$(2,2\theta)$ distribution. We're interested in $\mathbb{E}[X_{(n)}]$, the expectation of the maximum order statistic. I found that the CDF of $X_{(n)}$ is,

$$F_{X_{(n)}}(x) = \left(\frac{x-2}{2\theta-2}\right)^n \;\;\;\; 2 < x < 2\theta$$

The corresponding pdf is then,

$$f_{X_{(n)}}(x) = \frac{n(x-2)^{n-1}}{(2\theta-2)^n} \;\;\;\; 2 < x < 2\theta$$

I've been trying to calculate the expectation using two methods,

$$\mathbb{E}[X_{(n)}] = \int\limits_2^{2\theta}xf_{X_{(n)}}(x)dx \;\;\;\;\;\; \& \;\;\;\;\;\; \mathbb{E}[X_{(n)}] = \int\limits_2^{2\theta}(1-F_{X_{(n)}}(x))dx$$

However, I'm getting different results,

$$\int\limits_2^{2\theta}xf_{X_{(n)}}(x)dx = \int\limits_2^{2\theta}x\frac{n(x-2)^{n-1}}{(2\theta-2)^n}dx = \frac{2\theta n + 2}{n+1}$$ $$\int\limits_2^{2\theta}(1-F_{X_{(n)}}(x))dx = \int\limits_2^{2\theta}\left(1-\left(\frac{x-2}{2\theta-2}\right)^n\right)dx = \frac{2\theta n - 2n}{n+1}$$

Am I not applying the formula correctly? Under what conditions (other than $X$ being nonnegative) does the formula, $\mathbb{E}[X] = \int\limits_0^\infty(1-F_X(x))dx$, apply?

For the second integral, you should start integrating from $0$ rather than $2$, hence $$\int_0^\infty(1-F_{X_n}(x)dx = \int_0^21dx + \int_2^{2\theta}(1-F_{X_n}(x))dx = 2+\frac{2\theta n -2n}{n+1} = \frac{2\theta n+2}{n+1}$$ as desired.
Note: You can see this post for a proof that for non-negative random variable $X$, $$E(X) = \int_0^\infty\left(1-F_X(t)\right)dt$$
• Ah, I completely missed that $F_{X_{(n)}}(x) = 0$ on $[0,2]$. Thank you! – Flowsnake Jul 13 '17 at 5:18