Expected average of differences between two points in a uniform distribution

expected valueprobability

Let's say I have a discrete uniform distribution where a variable x can take any value between 1 to 100 (inclusive).

I spin up two values of x: x1 and x2 and they take the values 23 and 53 respectively.

The absolute difference between x1 and x2 is |x1 – x2| = 30.

The minimum absolute difference possible is 0 when x1 = x2 and the maximum is 100 when one of the two is 100 and the other is 0.

If I was to spin up pairs of (x1, x2) a gazillion times, what would be the expected average absolute difference?

Best Answer

I started with two die $(n=6)$ and made a table $$\begin{array}{|c|c|c|c|c|c|}\hline \text{die 1 / die 2 } & 1 &2 &3 &4 &5 &6 \\ \hline\hline \hline 1 & 0&1 &2 &3 &4 &5 \\ \hline 2 & 1 &0 &1 &2 &3&4 \\ \hline 3 &2 &1 &0 &1&2&3 \\ \hline 4 &3 &2 &1&0&1&2 \\ \hline 5 &4 &3&2&1&0 &1 \\ \hline 6 &5&4&3&2 &1 &0 \\ \hline\end{array}$$

For $|X_1-X_2|$ I got the following pmf

$f_{|X_1-X_2|}(x)=\begin{cases} \frac6{36}, \, x=0 \\ 2\cdot \frac{(6-x)}{36},\, x=\{1,2,3,4,5\} \\ 0, \, \textrm{elsewhere}\end{cases}$

From this smaller example I deduced the case $n=100$

$f_{|X_1-X_2|}(x)=\begin{cases} \frac{10}{100}, \, x=0 \\ 2\cdot \frac{(100-x)}{100},\, x=\{1,2,3\ldots , 99\} \\ 0, \, \textrm{elsewhere}\end{cases}$

Thus the expected value is

$$\mathbb E\left(|X_1-X_2| \right)=\sum_{x=1}^{99}x\cdot 2\cdot \frac{(100-x)}{100}=\frac{3333}{100}=33.33$$

To calculate it by hand it is good to know that $\sum\limits_{x=1}^{n-1} x^2=\frac16\cdot (n-1)\cdot n\cdot (2n-1)$. This is one approach to get the expected value.

For two discrete uniform random variables with outcomes from $1$ to $n$ we have

$$\mathbb E\left(|X_1^n-X_2^n| \right)=\frac{n^2-1}{3n}$$