Tutorials › Statistical Theory I - Probability and Distribution Theory › Moments and Covariances of Uniform Spacings

Ranks, Spacings, and Empirical Laws · Tutorial 480 of 994

Moments and Covariances of Uniform Spacings

Use the Dirichlet law of uniform spacings to calculate individual gap moments, dependence between distinct gaps, and variability of sums.

Advanced 10 min read

What You'll Learn

  • Define all \(n+1\) spacings, including the two endpoint gaps, for a sample of size \(n\).
  • Derive the first and second moments of a spacing from the Dirichlet density.
  • Calculate the covariance between any two distinct uniform spacings.
  • Find the variance of a sum of \(k\) selected gaps using the covariance structure.
  • Interpret the negative covariances as a consequence of the fixed total length.
  • Adjust spacing variances when the uniform sample lies on an interval other than \((0,1)\).

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:

$$ D_1=U_{(1)},\qquad D_i=U_{(i)}-U_{(i-1)}\ (2\leq i\leq n),\qquad D_{n+1}=1-U_{(n)}. $$

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.

Definition: A uniform spacing is one of the \(n+1\) consecutive gaps \(D_1,\ldots,D_{n+1}\), including the gap from 0 to the smallest observation and the gap from the largest observation to 1. A sum of \(k\) spacings means the sum of \(k\) distinct components of this vector.

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

$$ E\!\left[\prod_{i=1}^m X_i^{r_i}\right] = \frac{\Gamma(\alpha_0)}{\Gamma(\alpha_0+r_0)} \prod_{i=1}^m \frac{\Gamma(\alpha_i+r_i)}{\Gamma(\alpha_i)}. $$

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

$$ E\!\left[\prod_{i=1}^{n+1}D_i^{r_i}\right] = \frac{n!\prod_{i=1}^{n+1}r_i!}{(n+r_0)!}. $$

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

$$ E[D_i]=\frac{4!}{5!}=\frac{1}{5}. $$

For its second moment, take \(r_i=2\):

$$ E[D_i^2]=\frac{4!\,2!}{6!}=\frac{2}{5\cdot6}=\frac{1}{15}. $$

Therefore

$$ \operatorname{Var}(D_i)=E[D_i^2]-E[D_i]^2 =\frac{1}{15}-\frac{1}{25} =\frac{5-3}{75} =\frac{2}{75}. $$

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

$$ E[D_i]=\frac{1}{n+1},\qquad E[D_i^2]=\frac{2}{(n+1)(n+2)},\qquad E[D_iD_j]=\frac{1}{(n+1)(n+2)}\quad(i\ne j). $$

Subtracting products of means yields the variance and covariance. This proves the following formulas for every \(1\leq i,j\leq n+1\):

Theorem: For a sample of \(n\) independent \(U(0,1)\) observations, each spacing has \(\displaystyle E[D_i]=\frac{1}{n+1}\) and \(\displaystyle \operatorname{Var}(D_i)=\frac{n}{(n+1)^2(n+2)}\). For distinct spacings, \(\displaystyle \operatorname{Cov}(D_i,D_j)=-\frac{1}{(n+1)^2(n+2)}\).

Indeed, the variance calculation is

$$ \operatorname{Var}(D_i) =\frac{2}{(n+1)(n+2)}-\frac{1}{(n+1)^2} =\frac{2(n+1)-(n+2)}{(n+1)^2(n+2)} =\frac{n}{(n+1)^2(n+2)}. $$

For distinct \(i\) and \(j\), the covariance calculation is

$$ \operatorname{Cov}(D_i,D_j) =\frac{1}{(n+1)(n+2)}-\frac{1}{(n+1)^2} =\frac{(n+1)-(n+2)}{(n+1)^2(n+2)} =-\frac{1}{(n+1)^2(n+2)}. $$

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

$$ \operatorname{Var}(D_i)=\frac{4}{5^2\cdot6}=\frac{2}{75}, \qquad \operatorname{Cov}(D_i,D_j)=-\frac{1}{5^2\cdot6}=-\frac{1}{150} \quad(i\ne j). $$

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\):

$$ 0=\operatorname{Cov}\!\left(D_i,\sum_{j=1}^5D_j\right) =\operatorname{Var}(D_i)+\sum_{j\ne i}\operatorname{Cov}(D_i,D_j) =\frac{2}{75}+4\left(-\frac{1}{150}\right)=0. $$

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:

$$ \begin{aligned} \operatorname{Var}(S_A) &=k\frac{n}{(n+1)^2(n+2)} +k(k-1)\left(-\frac{1}{(n+1)^2(n+2)}\right)\\ &=\frac{k(n-k+1)}{(n+1)^2(n+2)}. \end{aligned} $$
Theorem: The sum of any \(k\) distinct spacings has mean \(\displaystyle \frac{k}{n+1}\) and variance \(\displaystyle \frac{k(n+1-k)}{(n+1)^2(n+2)}\). The result depends only on how many gaps are selected, not on their positions.

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:

$$ U_{(4)}-U_{(1)}=D_2+D_3+D_4. $$

Here \(k=3\) and \(n+1=6\). Its mean and variance are

$$ E[U_{(4)}-U_{(1)}]=\frac{3}{6}=\frac12, \qquad \operatorname{Var}(U_{(4)}-U_{(1)}) =\frac{3(6-3)}{6^2\cdot7} =\frac{9}{252} =\frac{1}{28}. $$

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

$$ \operatorname{Var}(D_2+D_3+D_4) =3\frac{5}{252}+6\left(-\frac{1}{252}\right) =\frac{15-6}{252} =\frac{1}{28}. $$

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

$$ L^2\frac{k(n+1-k)}{(n+1)^2(n+2)}. $$

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

$$ 10\frac{2}{4}=5. $$

Its variance is

$$ 10^2\frac{2(4-2)}{4^2\cdot5} =100\frac{4}{80} =5. $$

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:

$$ (n+1)\frac{n}{(n+1)^2(n+2)} +(n+1)n\left(-\frac{1}{(n+1)^2(n+2)}\right)=0. $$

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.

  1. 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?
  2. For \(n=6\), calculate the covariance between two distinct spacings.
  3. For \(n=4\), find the variance of the sum of any two distinct gaps.
  4. 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\).
  5. 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?