Let’s assume we have two random variables:
\[ X \sim p_X(x) \]
and
\[ Y \sim p_Y(y) \]
The expected distribution of the sum of two random variables is given by:
\[ U = X + Y \sim p_U(u) = \int_{-\infty}^\infty p_X(x) \cdot p_Y(u-x) dx \]
The expected distribution of the product of both variables is given by:
\[ V = X \cdot Y \sim p_V(v) = \int_{-\infty}^\infty \frac{1}{\mid x \mid} \cdot p_X(x) \cdot p_Y\left(\frac{v}{x}\right) dx \]
We want to test this results with an example.
For the following discussion we’ll use the uniform distributions for X and Y, i.e:
\[ X \sim p_X(x) = \frac{1}{L} \cdot \Pi_L(x) = \left\{ \begin{array} {rr} \frac{1}{L} : x \in (0, L) \\ 0 : x \in elsewhere \end{array} \right.\]
\[ Y \sim p_Y(y) = \frac{1}{L} \cdot \Pi_L(y) = \left\{ \begin{array} {rr} \frac{1}{L} : y \in (0, L) \\ 0 : y \in elsewhere \end{array} \right.\]
By applying the previous equations, and after a little mathematical work, we’ll find that:
\[ U = X + Y \sim p_U(u) = \Pi_L(u) \cdot \frac{u}{L^2} + \Pi_{[L, 2L]}(u) \cdot \frac{2L - u}{L^2} = \left\{ \begin{array} {rrr} \frac{u}{L^2} : u \in (0, L) \\ \frac{2L - u}{L^2} : u \in (L, 2L) \\ 0 : \in elsewhere \end{array} \right.\]
\[ V = X \cdot Y \sim p_V(v) = \frac{\Pi_{L^2}(v)}{L^2} \cdot \log(\frac{L^2}{v}) = \left\{ \begin{array} {rr} \frac{1}{L^2} \cdot \log(\frac{L^2}{v}) : u \in (0, L^2) \\ 0 : u \in elsewhere \end{array} \right.\]
Both random variables will be uniformly distributed:
n <- 5000
L <- 0.5
X <- runif(n, min = 0, max = L)
Y <- runif(n, min = 0, max = L)
And take a look at them:
par(mfrow=c(1,2))
hist(X, freq = FALSE, col = "lightgreen", breaks = 15, main = "X")
x <- seq(0, L, length.out = 250)
y <- dunif(x, min = 0, max = L)
lines(x, y)
hist(Y, freq = FALSE, col = "lightgreen", breaks = 15, main = "Y")
y <- dunif(x, min = 0, max = L)
lines(x, y)
par(mfrow=c(1,1))
Here we sample X + Y directly from samples in X and Y, and compare with the expected distribution:
hist(X + Y, freq = FALSE, col = "lightgreen", breaks = 30, main = "X + Y")
x <- seq(0, 2*L, length.out = 500)
y1 <- x/L^2
y2 <- 2/L - x/L^2
lines(x, y1)
lines(x, y2)
And do the same for the product:
hist(X * Y, freq = FALSE, col = "lightgreen", breaks = 30, main = "X * Y")
x <- seq(0, L^2, length.out = 500)
y <- 1/L^2*log(L^2/x)
lines(x, y)