# Derive method of moments estimator of $\theta$ for a uniform distribution on $(0, \theta)$

Let $$X_1, \ldots, X_n$$ be a random sample (i.i.d.) from a uniform distribution on $$[0, \theta]$$, where $$\theta$$ is unknown. Derive the method of moments estimator of $$\theta$$ and find its expectation and variance. Is this estimator consistent? Justify your answer.

Here I got the answer for expectation is $$\dfrac{\theta}{2}$$. Can anyone help with the variance please?

The method of moments estimator is obtained by solving $$E_\theta(X^r) = \frac{1}{n} \sum_{i=1}^n {X_i}^r$$. For $$r=1$$, one gets the expectation equality $$\begin{equation} E_\theta(X) = \int_0^\theta x\, \frac{1}{\theta} \, dx = \frac{\theta}{2} = \frac{1}{n} \sum_{i=1}^n {X_i} \, , \end{equation}$$ which yields an estimator for $$\theta$$ defined by $$\hat{\theta}_n = \frac{2}{n} \sum_{i=1}^n {X_i}$$ .
By virtue of the expectation's linearity and the sample's identical distribution, the expectation of this estimator is $$\begin{equation} E_\theta(\hat{\theta}_n) = \frac{2}{n} \sum_{i=1}^n E_\theta({X_i}) = \frac{2}{n}\, n \frac{\theta}{2} = \theta \, . \end{equation}$$ Therefore, the estimator is not biased.
Now, let us compute the variance of the estimator (which is also equal to the mean squared error since the estimator is not biased). Using the scaling and summation properties of the variance of uncorrelated random variables, one has $$\begin{equation} V_\theta(\hat{\theta}_n) = \frac{4}{n^2} \sum_{i=1}^n V_\theta({X_i}) = \frac{4}{n^2}\, n V_\theta({X}) \, . \end{equation}$$ Since the variance of the uniform law is $$\begin{equation} V_\theta(X) = E_\theta(X^2) - E_\theta(X)^2 = \frac{\theta^2}{3} - \left(\frac{\theta}{2}\right)^2 = \frac{\theta^2}{12} \, , \end{equation}$$ one obtains $$V_\theta(\hat{\theta}_n) = \dfrac{\theta^2}{3\, n}$$ .