Why Spacing Moments Matter
A sample of \(n\) independent uniform observations divides the interval from 0 to 1 into \(n+1\) random gaps. The gaps cannot vary independently: if one is unusually large, the others must together be smaller because all \(n+1\) gaps have a fixed sum. Their means and variances describe the typical size of a gap, while their covariances quantify this dependence. These calculations also make it possible to assess the variability of a whole interval formed by adding several adjacent gaps.
Let \(U_1,\ldots,U_n\) be independent \(U(0,1)\) random variables, and write their order statistics as \(U_{(1)}<\cdots<U_{(n)}\), an event of probability one. We include both endpoint gaps in the spacing vector:
There are \(n+1\) gaps, and \(\sum_{i=1}^{n+1}D_i=1\). By the Dirichlet law of uniform spacings, this vector has distribution \(\operatorname{Dirichlet}(1,\ldots,1)\): its density is constant, equal to \(n!\), on the \(n\)-dimensional simplex of positive coordinates summing to 1.
Moments from the Dirichlet Density
For a Dirichlet vector with positive parameters \(\alpha_1,\ldots,\alpha_m\), let \(\alpha_0=\sum_{i=1}^m\alpha_i\). Its density on the simplex is proportional to \(\prod_i x_i^{\alpha_i-1}\), with normalizing constant \(\Gamma(\alpha_0)/\prod_i\Gamma(\alpha_i)\). Consequently, for nonnegative integers \(r_1,\ldots,r_m\), and \(r_0=\sum_i r_i\), integrating the monomial against this density gives
To see why the ratio has this form, the simplex integral of \(\prod_i x_i^{\beta_i-1}\) is \(\prod_i\Gamma(\beta_i)/\Gamma(\sum_i\beta_i)\) for positive \(\beta_i\). This identity follows by writing the product of gamma integrals in positive coordinates \(y_i\), then setting \(t=\sum_i y_i\) and \(x_i=y_i/t\). The Jacobian is \(t^{m-1}\), so the integral factors into a gamma integral in \(t\) and the simplex integral in \(x\). Applying the identity first with \(\beta_i=\alpha_i+r_i\) and then using the Dirichlet normalizing constant gives the displayed moment formula.
For uniform spacings, \(m=n+1\) and every \(\alpha_i=1\). The integer-argument identity \(\Gamma(q+1)=q!\) then gives the convenient formula
Worked Example: The Mean and Variance of One Gap
Suppose \(n=4\), so there are five spacings. For any one of them, choose \(r_i=1\) and set the other exponents to zero. The moment formula gives
For its second moment, take \(r_i=2\):
Therefore
The mean is \(1/5\), as symmetry and the fact that the five gaps sum to 1 suggest. The variance describes the nonzero spread around that mean.
Means, Variances, and Covariances
The same calculation applies to every spacing, including the endpoint gaps. For the mean, set one exponent equal to 1. For a second moment, set one exponent equal to 2. For the product of two distinct gaps, set two exponents equal to 1. These choices give
Subtracting products of means yields the variance and covariance. This proves the following formulas for every \(1\leq i,j\leq n+1\):
Indeed, the variance calculation is
For distinct \(i\) and \(j\), the covariance calculation is
The negative sign is a mathematical expression of the fixed-total constraint. It is not merely a qualitative intuition: every pair of distinct gaps has the same strictly negative covariance.
Worked Example: Checking Dependence for Five Gaps
For \(n=4\), there are five gaps. The preceding formulas give
The covariance can also be checked from the fact that the sum of all five gaps is constant. Fix \(i\), and use \(D_1+\cdots+D_5=1\):
Thus the covariance value is consistent with the exact simplex constraint. This check alone does not determine the covariance without symmetry, but it verifies that the five equal cross-covariances balance each gap's variance.
Variance of a Sum of Gaps
Let \(A\) be any fixed set of \(k\) distinct gap indices, where \(1\leq k\leq n+1\), and define \(S_A=\sum_{i\in A}D_i\). Linearity of expectation gives \(E[S_A]=k/(n+1)\). To find its variance, expand the variance of the sum into individual variances and pairwise covariances. There are \(k\) variance terms and \(k(k-1)\) ordered cross terms:
The count \(k(k-1)\) matters: when a variance is expanded, each unordered pair appears twice, as both \(\operatorname{Cov}(D_i,D_j)\) and \(\operatorname{Cov}(D_j,D_i)\). Equivalently, one may count \(\binom{k}{2}\) pairs and multiply their sum by 2.
Worked Example: The Gap from the First to the Fourth Order Statistic
Take a sample of \(n=5\) observations. The distance from the first to the fourth order statistic is the sum of three consecutive gaps:
Here \(k=3\) and \(n+1=6\). Its mean and variance are
For a direct covariance check, each of the three gaps has variance \(5/(36\cdot7)=5/252\), and each distinct pair has covariance \(-1/252\). Thus
The six cross terms are the two covariance terms for each of the three unordered pairs. Omitting that factor of two would give an incorrect variance.
Intervals Other Than the Unit Interval
If \(X_1,\ldots,X_n\) are independent uniform observations on an interval \((a,b)\) of length \(L=b-a>0\), their ordered gaps, including both endpoint gaps, are \(L\) times the corresponding \(U(0,1)\) spacings. Multiplication by \(L\) multiplies means by \(L\), and variances and covariances by \(L^2\). In particular, a sum of \(k\) gaps has mean \(Lk/(n+1)\) and variance
Worked Example: A Sum of Gaps on a Length-10 Interval
Let \(n=3\) observations be uniform on \((2,12)\), an interval of length \(L=10\). The distance from the smallest to the largest observation is the sum of the two interior gaps, so \(k=2\). Its mean is
Its variance is
The variance is in squared length units. The mean and variance scale differently: doubling the interval length doubles the mean spacing but multiplies its variance by four.
Common Mistake and Practical Use
A frequent error is to treat the gaps as independent because each has the same marginal distribution. Identical distributions do not imply independence. For distinct spacings here, the covariance is negative, and independence would incorrectly force it to be zero. Another error is to calculate the variance of a sum using only the individual variances. The covariance terms are essential; in fact, they reduce the variance of a sum of several gaps.
The fixed-total identity provides a useful diagnostic. Since \(\sum_iD_i=1\), the variance of the sum must be zero. Substituting the common variance and covariance confirms this:
For a partial sum, the formula also has sensible boundary checks. With \(k=1\), it gives the variance of one gap. With \(k=n+1\), it gives zero because the sum is the constant 1. A sum of \(k\) gaps can also be viewed as a grouped spacing; its variability depends on the group size, while the negative covariances ensure that its complement moves in the opposite direction.
Check Your Understanding
Use the formulas in this tutorial to answer the following questions.
- For a sample of size \(n\), what is the mean of an endpoint spacing, and why is it the same as the mean of an interior spacing?
- For \(n=6\), calculate the covariance between two distinct spacings.
- For \(n=4\), find the variance of the sum of any two distinct gaps.
- Explain why the variance of the sum of all \(n+1\) gaps must be zero, and verify that the formula for a sum of \(k\) gaps gives this when \(k=n+1\).
- If the sampling interval has length \(L\), by what factor does the variance of a sum of gaps change compared with the unit-interval case?