Two random variables and
are independent and uniform on
. What is the expected value of their difference, and what is the expected value of their absolute difference?

The Problem: In a probability drill reported by candidates from a 2021 Afiniti interview, a caller score and an agent score
are independent draws from Uniform[0, 1]. With no calculator and five minutes, you must give the expected signed gap and the expected absolute gap, choosing between the whiteboard candidates 0, 1/4, 1/3 and 1/2.
Answer
The signed difference has expected value zero, because linearity gives and needs no independence at all. The absolute difference cannot cancel, since
folds the negative half of the gap onto the positive half. Integrating
over the unit square and splitting at the diagonal gives
. The order-statistics shortcut reaches the same number in one line, because
with expectations 2/3 and 1/3. Equivalently, the two points cut
into three exchangeable spacings of expected length 1/3 each, and the gap is the middle one.
(1) Signed Gap Is Zero: Linearity of expectation needs only finite means, so even for dependent pairs. Under independence
has the triangular density
on
, symmetric about zero.
(2) Absolute Gap Is 1/3, Not 1/2: Folding the triangle gives , which piles probability near zero, so the mean lands at 1/3. The gut answer 1/2 overweights large gaps that are actually rare.
(3) Tail Area Route: The event is two corner triangles with legs
, so
and integrating that tail probability gives 1/3.
(4) Order Statistics Route: gives
, and symmetry gives
. Their difference is the gap, so the answer follows with no integration beyond a CDF.
(5) Spread Check: , so
and the gap has a standard deviation of about 0.236.
Mathematical Formulation:
Where:
and
are independent Uniform[0, 1] variables with mean
each, so their joint density is 1 on the unit square;
is the absolute gap.
and
are integration variables; the factor 2 comes from the symmetry of the triangles above and below the diagonal
, and the inner integral
equals
.
is a gap threshold,
is the combined area of two corner triangles, and
is its negative derivative, the density of the gap.
is a dummy variable in the tail-integral identity
, valid for any nonnegative
.
and
are the order statistics;
follows from the density
and
from
.

Figure 1: (a) The event is two corner triangles of area 1/8 each, so its probability is 1/4. (b) The signed gap has the triangular density
, symmetric with mean 0. (c) Folding gives
, and 200,000 simulated pairs match it with mean 1/3, well below the gut guess 1/2.
Worked Example:
Replace each uniform by a fair draw from the four midpoints 0.125, 0.375, 0.625 and 0.875, so all 16 ordered pairs are equally likely. Four pairs have gap 0, six have gap 0.25, four have gap 0.5, and two have gap 0.75. The mean absolute gap is , while the signed gaps cancel pair by pair to exactly 0. For
midpoints the same count gives
, which is 0.25 at
and 0.33 at
, approaching 1/3 from below. That convergence is a quick sanity check that the continuous answer is 1/3 and not 1/2.
All three derivation routes reach 1/3, but they differ in how fast they fit on a whiteboard and in what they generalize to. The order-statistics route is the fastest under interview pressure, the double integral is the one that survives a change of joint density, and the tail route answers follow-up questions about medians and threshold probabilities for free.
| Property | Order statistics | Double integral | Tail integral |
|---|---|---|---|
| Key step | Gap = max – min, with E[max] = 2/3 and E[min] = 1/3 | Split the unit square at the diagonal y = x | P(D > d) = (1 – d)^2 from two corner triangles |
| Whiteboard length | Two lines | Four lines | Three lines |
| Generalizes to | Expected range of n uniforms, (n – 1)/(n + 1) | Any joint density, including dependent pairs | Medians, quantiles and threshold probabilities of the gap |
| Common slip | Assuming E[max] of two uniforms is 1 | Dropping the factor 2 and answering 1/6 | Counting only one corner triangle, which also gives 1/6 |
Leave a Reply