# What distribution does the mean of a random sample from a Uniform distribution follow?

For example, let $$X_1,\cdots,X_n$$ be a random sample from $$f(x|\theta)=1,\theta-1/2 < x < \theta +1/2$$. Clearly, $$X_i \sim U(\theta-1/2 , \theta +1/2)$$. Some intuition would suggest that $$\bar{X}\sim f(x|\theta)=1,\theta-1/2 < x < \theta +1/2$$. However, I do not think that this is actually correct. What distribution would $$\bar{X}$$ follow?

• Please see the central limit theorem: lots here on that!
– Ed V
Commented Apr 3, 2020 at 19:42
• Up to a factor of $\theta/n$ and a shift by $-n/2,$ both of which are readily understandable and computable, it's the distribution described (in great detail, with no approximation) at stats.stackexchange.com/questions/41467.
– whuber
Commented Apr 3, 2020 at 22:06
• @whuber both the question and your answer are fantastic on that link- thank you for sharing! Commented Apr 3, 2020 at 22:32
• I followed the link by whuber and it is his usual absolutely esquisite and thorough answer! There should be a Hall of Fame for answers like that. Come to think of it, it is probably distributed throughout this site: lots of seriously heavy hitters here and all I can do is marvel, from the cheap seats, at what they produce!
– Ed V
Commented Apr 3, 2020 at 22:53
• One last comment. Whenever I see an astonishingly good answer here, I am reminded of a line from Butch Cassidy and the Sundance Kid: "Who are these guys?"
– Ed V
Commented Apr 3, 2020 at 23:04

First, you might want to look at Wikipedia on Irwin-Hall distribution.

Unless $$n$$ is very small $$A = \bar X = \frac{1}{n}\sum_{i=1}^{n} X_i,$$ where $$X_i$$ are independently $$\mathsf{Unif}(\theta-.5,\theta+.5)$$ has $$A \stackrel{aprx}{\sim}\mathsf{Norm}(\mu = \theta, \sigma = 1/\sqrt{12n}).$$

[The approximation is quite good for $$n \ge 10.$$ In fact, in the early days of computation when it was expensive to do operations other than pain arithmetic, a common way to simulate a standard normal random variable was to evaluate $$Z = \sum_{1=1}^{12} X_i - 6,$$ where $$X_i$$ were generated as independently standard uniform.]

The following simulation in R uses a million samples of size $$n = 12$$ with $$\theta = 5.$$

set.seed(2020)  # for reproducibility
m = 10^6;  n = 12;  th = 5
a = replicate(m, mean(runif(n, th-.5,th+.5)))
mean(a);  sd(a); 1/sqrt(12*n)
[1] 5.000153      # aprx 5
[1] 0.08339642    # aprx 1/12
[1] 0.08333333    # 1/12


Thus the mean and standard deviations are consistent with the results of the Central Limit Theorem. In R, the Shapiro-Wilk normality test is limited to 5000 observations. We show results for the first 5000 simulated sample means. Those observations are consistent with a normal distribution.

shapiro.test(a[1:5000])

Shapiro-Wilk normality test

data:  a[1:5000]
W = 0.99979, p-value = 0.9257


The histogram below compares the simulated distribution of $$\bar X$$ with the PDF of $$\mathsf{Norm}(\mu=5, \sigma=1/12).$$

hdr = "Simulated Dist'n of Means of Uniform Samples: n = 12"
hist(a, br=30, prob=T, col="skyblue2", main=hdr)
curve(dnorm(x, 5, 1/sqrt(12*n)), add=T, lwd=2)
abline(v=5+c(-1,1)*1.96/sqrt(12*n), col="red")


This suggests that $$P\left(-1.96 < \frac{\bar X - \theta}{1/\sqrt{12n}} < 1.96\right) = 0.95,$$ so that a very good approximate 95% confidence interval for $$\theta$$ is of the form $$(\bar X \pm 1.96/\sqrt{12n}).$$

• Do you know a reference where that approximation to the normal was used? Commented Apr 4, 2020 at 16:03
• (1) I'm old enough to remember using it. (2) Mention: penultimate parag here. (3) Temporarily separated from my older simulation books, but method often mentioned. (4) Method can't produce values beyond $\pm 6.$ When computing logs and exponentials became cheap, it was replaced by the Box-Muller method.which gives values roughly btw $\pm 6.67.$ (5) R now uses Wichura's rational aprx to std norm quantile fcn,: accurate to double precision, Commented Apr 4, 2020 at 19:29
• References: The method to sum 12 standard uniform random variables and subract 6 (among others) is discussed and extended in Thomas, Luk, Leung & Villasenor, ACM V39, Nr4, Article 11, Sect 2.2.2. It is a problem is several applied probability books, including Suess (2010), Springer: Problem 2.15 p48, (The Box-Muller method is discussed there in Sect. 2.5 p36-38.) Commented Apr 4, 2020 at 23:10
• I did not expect to find such a lovely relationship between the sum of uniform random variables and the standard normal distribution. This is fantastic- thank you! Commented Apr 5, 2020 at 23:47

No, it's not uniform. Intuitively, you would expect that the uncertainty over $$\bar X$$ decreases as $$n$$ increases. Also the central limit theorem suggests, as $$n$$ increases, the distribution approaches normal distribution. Which means, you'll have a peak around $$\theta$$, and it's going to narrow down as $$n\rightarrow\infty$$.

For a simple counter-example, if $$n=2$$, $$\bar X$$ is going to have triangular distribution, with its center at $$\theta$$, with the same limits.

• I see. By applying CLT, we get that $\bar{X}$ is asymptotically normal. I was hoping to find some function of the sample that is a pivotal quantity, but I guess I cannot use $\bar{X}$ Commented Apr 3, 2020 at 21:09
• Does this example's mean follow a known distribution, non-asymptotically? Commented Apr 3, 2020 at 22:27
• @Edison whuber's post give a detailed answer on your query for the general case. and Bruce's answer exemplifies the implications of CLT to your case very well. I was lazy enough to answer for the general case since it wasn't directly asked in your question, but was nearly sure that the general case was answered before in this forum (of course with some volume of explanation inside it) however couldn't spotted it. This is a counter-example for your original question :) Commented Apr 4, 2020 at 19:43
• I appreciate the counter-example and your effort. Thank you! Commented Apr 5, 2020 at 23:43

The Irwin-Hall distribution is the distribution of a sum of $$n$$ uniform random variables. Therefore, an analytic expression for the density of the mean of $$n$$ uniform random variables is

$$\frac{1}{n!} \sum_{k=0}^n (-1)^k \binom{n}{k} (x-k)_+^{n-1}$$

By shifting this expression, you get the density of yours.

• Thank you for sharing this. I appreciate it! Commented Apr 5, 2020 at 23:45

This is one case where using Fourier transforms makes for simple solutions. Your density function is $$\mathrm{rect}(\theta)$$ with its Fourier transform $$\mathrm{sinc}(f)$$ (where $$\mathrm{sinc}(f)=\frac{\sin \pi f}{\pi f}$$ with the obvious continuation $$\mathrm{sinc}(0)=1$$). Adding $$n$$ variables with that distribution leads to convolving the distribution $$n$$ times with itself (and dividing by $$n$$), so the resulting distribution has the Fourier transform $$\bigl(\mathrm{sinc}(f)\bigr)^n\over n$$. Doing the inverse transform then delivers $$\int_{-\infty}^\infty \cos(2\pi f\theta){\bigl(\mathrm{sinc}(f)\bigr)^n\over n}\,\mathrm{d}f$$. In contrast to the piece-wise defined function in the $$\theta$$ domain, this is a single expression and thus properties like the moments of the function can be derived from this representation through the Fourier domain.

• Thank you for sharing a unique explanation. Love seeing the different ways that can explain certain concepts. Commented Apr 5, 2020 at 23:44