Distance from a Fixed Threshold
For a random variable \(X\), the quantity \(|X-a|\) measures the distance between its realized value and a fixed number \(a\). Its expectation, \(E[|X-a|]\), is therefore the average distance from that threshold under the distribution of \(X\). The absolute value makes the calculation depend on which side of \(a\) each possible value lies: below \(a\), the distance is \(a-X\); above \(a\), it is \(X-a\).
The threshold is fixed while the random variable varies. It need not be a value in the support, and it need not be the mean or any other summary of the distribution. The essential calculation is to split the sum or integral at \(a\), while respecting the support of \(X\).
These are applications of LOTUS: apply the function \(g(x)=|x-a|\) to the distribution of \(X\). Since \(g\) is nonnegative, its expectation is defined even if the sum or integral diverges; it is finite precisely when the corresponding sum or integral is finite. When calculating it, the useful pointwise identity is
At \(x=a\), both terms on the right are zero. Thus mass at the threshold contributes nothing, and it is safe to use strict inequalities on both sides.
Splitting the Calculation at the Threshold
For a discrete random variable, split its possible values into those below \(a\), equal to \(a\), and above \(a\). The equality case has zero contribution, so the formula becomes
For a continuous random variable with density \(f\), the corresponding split is
The value of the integrand at the single point \(a\) does not affect an ordinary density integral. In either formula, the support may shorten or eliminate one of the pieces. For instance, if all possible values satisfy \(x\ge a\), only the distance \(x-a\) needs to be averaged.
Proof. The triangle inequality gives \(|X-a|\le |X|+|a|\) and \(|X|\le |X-a|+|a|\). Taking expectations of these nonnegative quantities shows that finiteness of either expectation implies finiteness of the other, because \(a\) is fixed and finite. Thus the absolute deviation cannot be made finite by shifting an \(X\) whose absolute expectation is infinite. \(\square\)
Worked Example: A Discrete Distribution With Mass at the Threshold
Suppose \(X\) takes values \(-2\), \(1\), and \(5\), with probabilities \(0.2\), \(0.5\), and \(0.3\), respectively. Find \(E[|X-1|]\).
The threshold is \(a=1\). The value \(-2\) is below it, \(5\) is above it, and \(1\) is exactly at it. The distances are
Weight each distance by its probability:
The probability at the threshold is \(0.5\), but it contributes zero to the expected distance. The probabilities sum to \(0.2+0.5+0.3=1\), as required.
Worked Example: A Threshold Inside a Continuous Support
Let \(X\) have the uniform distribution on \([0,4]\), with density \(f(x)=1/4\) on that interval and zero elsewhere. Find \(E[|X-1|]\).
The support extends both below and above \(a=1\), so both parts of the split are needed:
For the first integral,
For the second,
Therefore,
The two pieces differ in size because the support extends three units above the threshold but only one unit below it. The result is finite, as expected for a variable with bounded support.
Worked Example: A Threshold Below the Entire Support
Let \(X\) be uniform on \([2,5]\), and take \(a=1\). Since every possible value of \(X\) exceeds the threshold, the below-threshold integral vanishes. The density is \(1/3\) on \([2,5]\), so
Evaluating the endpoints gives
As a check, the mean of a uniform distribution on \([2,5]\) is \((2+5)/2=7/2\), and here \(X-1\) is always nonnegative. Thus \(E[|X-1|]=E[X-1]=7/2-1=5/2\), agreeing with the integral.
Worked Example: An Exponential Distribution Split at a Positive Threshold
Suppose \(X\) has an exponential distribution with rate \(2\), so its density is \(f(x)=2e^{-2x}\) for \(x\ge0\). Find \(E[|X-1|]\). The support begins at zero, and the threshold \(1\) lies inside it:
For the first piece, the probability below 1 is \(1-e^{-2}\), and
Subtracting this truncated first moment from the probability gives
For the second piece, use \(y=x-1\). Then \(x=y+1\), and
The last integral equals the mean \(1/2\) of an exponential distribution with rate 2. Adding the pieces yields
Why the Split Is Essential
The absolute value changes its algebraic form at the threshold. Replacing \(|X-a|\) by \(X-a\) across the whole support would assign negative values to observations below \(a\), even though a distance cannot be negative. Replacing it by \(a-X\) everywhere creates the corresponding error above \(a\). Splitting first prevents either mistake.
There is also a useful finiteness check. The theorem above shows that for any fixed finite threshold, the expected absolute deviation is finite exactly when \(E[|X|]\) is finite. In a particular calculation, the two pieces are nonnegative, so neither can cancel an infinite contribution from the other. For example, a divergent integral on one side cannot be offset by a negative integral on the other.
A reliable procedure is to identify the support, locate \(a\) relative to that support, and then use \(a-x\) below the threshold and \(x-a\) above it. Include a term at \(x=a\) if listing discrete outcomes, but note that its contribution is zero. Finally, check the arithmetic and, for an unbounded support, whether the resulting nonnegative integral is finite.
Check Your Understanding
Use the support and the threshold to decide how to set up each calculation before evaluating it.
- A variable takes values \(0\) and \(3\) with probabilities \(0.4\) and \(0.6\). Write the split-sum calculation for \(E[|X-2|]\).
- If \(X\) is uniform on \([0,6]\), which integral pieces are needed to calculate \(E[|X-4|]\)?
- Suppose \(X\ge 5\) with probability 1 and \(a=2\). Why is there no below-threshold contribution?
- Why does a discrete atom at \(x=a\) contribute zero to \(E[|X-a|]\)?
- Can a finite fixed threshold make \(E[|X-a|]\) finite when \(E[|X|]\) is infinite? Explain using the triangle inequality.