4
$\begingroup$

If I have two independent variables $x$ and $y$ with a uniform distribution between -1 and 1. How would I calculate the expected value of their absolute sum. e.g.

$E(|x + y|)$

I wrote some code to brute force this here https://jsbin.com/xorixa/edit?js,console

The result comes out to be $2/3$ but my question is how would I go about calculating this.

3 Answers 3

2

$$E(x, y) = \frac{\int_{-1}^{1}\int_{-1}^{1} |x+y| ~dydx}{\int_{-1}^{1}\int_{-1}^{1} (1) ~dydx } = \frac{\int_{-1}^{1}\int_{-1}^{1} |x+y| ~dydx}{4 }$$

$|x+y| = x+y$ when $x+y \geq 0$, meaning $y \geq -x$. Alternatively, $|x+y| = -(x+y)$ when $y \leq -x$.

$$E(x,y) = \frac{\int_{-1}^{1}\int_{-1}^{-x} -(x+y) ~dydx + \int_{-1}^{1}\int_{-x}^{1} (x+y) ~dydx}{4 }$$

$$E(x,y) = \frac{\frac{8}{3}}{4 } = \frac{2}{3}$$

2

@Marcus Andrews A solution without double integrals is also possible:

If $X_1$ and $X_2$ are two independent uniformly distributed RV on $[-a,a]$, the pdf of RV $X=X_1+X_2$ is the "tent" function defined by $f(x)=\dfrac{1}{2a}\left(1-\dfrac{|x|}{2a}\right)$, here with $a=1.$

Thus, $f$ being an even function, the pdf of $|X|$ is

$g(x)=2 f(x)=2 \dfrac{1}{2}\left(1-\dfrac{x}{2}\right) = 1-\dfrac{x}{2} \ \ x \in [0,2]$ (and $0$ elsewhere).

Therefore,

$$E(|X|)=\int_0^2 xg(x)dx=\int_0^2 \left(x-\dfrac{x^2}{2}\right)dx=2-\dfrac{2^3}{6}=\dfrac23$$

1

Since the variables $X, Y$ are independent, their joint density function is $f(x,y) = f_X(x)f_Y(y) = 1/4$ when $x, y \in [-1, 1]$ and $f(x,y) = 0$ otherwise. Therefore to find the expectation you need only calculate the integral $ (1/4) \int_{-1}^1 \int_{-1}^{1} |x+y|dx dy$. If you split up the domain based on the sign of $x + y$ this should not be too difficult to calculate.