Confidence interval for the mean of the uniform distribution I can take samples of a random variable $X \sim U(a, b)$, where the length of $(a, b)$ is known. I am interested in its mean $E[X]$, estimated with $\hat{X_n} = \frac{1}{n} \sum_{i=1}X_n$, but I need some guarantees for this estimate. Specifically, given a $\delta > 0$, I want to find out how many samples I should take s.t. $(\hat{X_n} - \delta, \hat{X_n} + \delta)$ is a 95% confidence interval.
I would know how to do this for a normally distributed random variable, but I'm not sure about the uniform case. Maybe a very similar or even the same procedure can be justified using the CLT?
 A: *

*The central limit theorem applies in this situation and the normal approximation is actually good for fairly low numbers of observations (with $n=20$ you should be pretty safe).


*However, the midrange (maximum+minimum)/2 is a better estimate than the mean; it has a smaller variance and therefore allows for smaller confidence intervals at the same level.


*I don't have the time to look for the exact distribution of the midrange but it may be derived somewhere (sorry, incomplete answer). I don't think I have seen it written down in closed form but I'm pretty sure it can be done, although it may look complex. The Wikipedia page
https://en.wikipedia.org/wiki/Continuous_uniform_distribution#Estimation_of_midpoint
does it for the situation that the lower boundary is known to be zero, which is somewhat easier (more precisely, one can easily derive a CI for half the maximum, which in that case estimates the mean, from what is given there).
One can also simulate it (and use equivariance properties for generalising to arbitrary values a and b) or use bootstrap.


*It may be that knowledge of the length (b-a) can be used to improve the confidence interval even more, but I'm not quite sure how. This would require more time than I'd be willing to put into a Cross-Validated answer.
