Tutorials › Statistical Theory I - Probability and Distribution Theory › Absolute Deviations from a Fixed Threshold

Expectation and LOTUS · Tutorial 317 of 994

Absolute Deviations from a Fixed Threshold

Split the distribution at a fixed threshold to calculate expected absolute deviation correctly, including when the threshold lies outside the support.

Intermediate 9 min read

What You'll Learn

  • Express absolute deviation as two nonnegative pieces on either side of a threshold.
  • Set up discrete sums and continuous integrals with the correct split point.
  • Use the support to simplify calculations when a threshold lies outside the possible values.
  • Handle an observation or atom exactly at the threshold.
  • Check whether the expected absolute deviation is finite.

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

Definition: For a random variable \(X\) and fixed \(a\in\mathbb{R}\), the absolute deviation from \(a\) is the random variable \(|X-a|\). Its expected absolute deviation is \(E[|X-a|]\), interpreted as an extended nonnegative expectation if it is not finite. If \(X\) is discrete with mass function \(f\), then $$ E[|X-a|]=\sum_x |x-a|f(x). $$ If \(X\) has density \(f\), then $$ E[|X-a|]=\int_{-\infty}^{\infty}|x-a|f(x)\,dx. $$

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

$$ |x-a|=(a-x)\mathbf{1}_{\{x<a\}}+(x-a)\mathbf{1}_{\{x>a\}}. $$

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

$$ E[|X-a|] = \sum_{x<a}(a-x)f(x) + \sum_{x>a}(x-a)f(x). $$

For a continuous random variable with density \(f\), the corresponding split is

$$ E[|X-a|] = \int_{-\infty}^{a}(a-x)f(x)\,dx + \int_{a}^{\infty}(x-a)f(x)\,dx. $$

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.

Theorem: For any random variable \(X\) and any fixed finite \(a\), \(E[|X-a|]\) is finite if and only if \(E[|X|]\) is finite.

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

$$ |-2-1|=3,\qquad |1-1|=0,\qquad |5-1|=4. $$

Weight each distance by its probability:

$$ E[|X-1|] =3(0.2)+0(0.5)+4(0.3) =0.6+0+1.2 =1.8. $$

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:

$$ E[|X-1|] =\frac14\int_0^1(1-x)\,dx +\frac14\int_1^4(x-1)\,dx. $$

For the first integral,

$$ \int_0^1(1-x)\,dx =\left[x-\frac{x^2}{2}\right]_0^1 =1-\frac12 =\frac12. $$

For the second,

$$ \int_1^4(x-1)\,dx =\left[\frac{x^2}{2}-x\right]_1^4 =(8-4)-\left(\frac12-1\right) =\frac92. $$

Therefore,

$$ E[|X-1|]=\frac14\left(\frac12+\frac92\right)=\frac54. $$

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

$$ E[|X-1|] =\frac13\int_2^5(x-1)\,dx =\frac13\left[\frac{x^2}{2}-x\right]_2^5. $$

Evaluating the endpoints gives

$$ \frac13\left(\frac{25}{2}-5-(2-2)\right) =\frac13\cdot\frac{15}{2} =\frac52. $$

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:

$$ E[|X-1|] =\int_0^1(1-x)2e^{-2x}\,dx +\int_1^\infty(x-1)2e^{-2x}\,dx. $$

For the first piece, the probability below 1 is \(1-e^{-2}\), and

$$ \int_0^1 2xe^{-2x}\,dx =\left[-\left(x+\frac12\right)e^{-2x}\right]_0^1 =\frac12-\frac32e^{-2}. $$

Subtracting this truncated first moment from the probability gives

$$ \int_0^1(1-x)2e^{-2x}\,dx =(1-e^{-2})-\left(\frac12-\frac32e^{-2}\right) =\frac12+\frac12e^{-2}. $$

For the second piece, use \(y=x-1\). Then \(x=y+1\), and

$$ \int_1^\infty(x-1)2e^{-2x}\,dx =e^{-2}\int_0^\infty 2ye^{-2y}\,dy =\frac12e^{-2}. $$

The last integral equals the mean \(1/2\) of an exponential distribution with rate 2. Adding the pieces yields

$$ E[|X-1|]=\frac12+e^{-2}\approx 0.6353. $$

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.

Common pitfall: Writing \(E[|X-a|]=|E[X]-a|\) treats the absolute value of an average as if it were the average of absolute values. These are generally different. In the discrete example above, \(E[X]=(-2)(0.2)+(1)(0.5)+(5)(0.3)=1.6\), so \(|E[X]-1|=0.6\), whereas \(E[|X-1|]=1.8\). The correct calculation applies LOTUS to \(|x-a|\), splitting at \(a\).

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.

  1. A variable takes values \(0\) and \(3\) with probabilities \(0.4\) and \(0.6\). Write the split-sum calculation for \(E[|X-2|]\).
  2. If \(X\) is uniform on \([0,6]\), which integral pieces are needed to calculate \(E[|X-4|]\)?
  3. Suppose \(X\ge 5\) with probability 1 and \(a=2\). Why is there no below-threshold contribution?
  4. Why does a discrete atom at \(x=a\) contribute zero to \(E[|X-a|]\)?
  5. Can a finite fixed threshold make \(E[|X-a|]\) finite when \(E[|X|]\) is infinite? Explain using the triangle inequality.