[Math] calculate the Probability density function of the absolute difference of two random variable

probability distributions

If $X$ and $Y$ are two independent random variables with probability density functions $f$ and $g$, respectively, then the probability density of the difference $Y − X$ is given by the cross-correlation . In contrast, the convolution f * g gives the probability density function of the sum $X + Y$.

what i would like to have is the probability density functions of $|y-x|$ or $(y-x)^2$. Is that possible ?

is that the equivalent as doing the following with two histogram ?

for (bin b1 in Histogram1)
  for (bin b2: Histogram2)
        prob = b1.probability * b2.probability
        distance += prob * abs(b1.value - b2.value)

Best Answer

As you said, the density of $X-Y$ is the cross-correlation $h(t) = \int_{-\infty}^\infty f(t+y) g(y) \, dy$. The density of $|X-Y|$ is $f_{|X-Y|}(t) = h(t) + h(-t)$ for $t > 0$, $0$ for $t < 0$. The density of $(X-Y)^2$ is $f_{(X-Y)^2}(t) = (h(\sqrt{t}) + h(-\sqrt{t}))/(2 \sqrt{t})$ for $t > 0$, $0$ for $t < 0$.