# pdf of a product of two independent Uniform random variables

Let $X$ ~ $U(0,2)$ and $Y$ ~ $U(-10,10)$ be two independent random variables with the given distributions. What is the distribution of $V=XY$?

I have tried convolution, knowing that

$$h(v) = \int_{y=-\infty}^{y=+\infty}\frac{1}{y}f_Y(y) f_X\left (\frac{v}{y} \right ) dy$$

We also know that $f_Y(y) = \frac{1}{20}$,

$$h(v)= \frac{1}{20} \int_{y=-10}^{y=10} \frac{1}{y}\cdot \frac{1}{2}dy$$ $$h(v)=\frac{1}{40}\int_{y=-10}^{y=10} \frac{1}{y}dy$$

• If this is a homework question could you please add the self-study tag? Thank you!
– Andy
Jan 25, 2015 at 18:42
• could this not be a uniform RV? Jan 25, 2015 at 18:45
• It doesn't look like uniform. maybe something with log? But I don't know how to write it out since zero is in between the bounds, and the function is undefined at zero.
– cgo
Jan 25, 2015 at 18:53

A fine, rigorous, elegant answer has already been posted. The purpose of this one is to derive the same result in a way that may be a little more revealing of the underlying structure of $XY$. It shows why the probability density function (pdf) must be singular at $0$.

Much can be accomplished by focusing on the forms of the component distributions:

• $X$ is twice a $U(0,1)$ random variable. $U(0,1)$ is a standard, "nice" form characteristic of all uniform distributions.

• $|Y|$ is ten times a $U(0,1)$ random variable.

• The sign of $Y$ follows a Rademacher distribution: it equals $-1$ or $1$, each with probability $1/2$.

(This last step converts a non-negative variate into a symmetric distribution around $0$, both of whose tails look like the original distribution.)

Therefore $XY$ (a) is symmetric about $0$ and (b) its absolute value is $2\times 10=20$ times the product of two independent $U(0,1)$ random variables.

Products often are simplified by taking logarithms. Indeed, it is well known that the negative log of a $U(0,1)$ variable has an Exponential distribution (because this is about the simplest way to generate random exponential variates), whence the negative log of the product of two of them has the distribution of the sum of two Exponentials. The Exponential is a $\Gamma(1,1)$ distribution. Gamma distributions with the same scale parameter are easy to add: you just add their shape parameters. A $\Gamma(1,1)$ plus a $\Gamma(1,1)$ variate therefore has a $\Gamma(2,1)$ distribution. Consequently

The random variable $XY$ is the symmetrized version of $20$ times the exponential of the negative of a $\Gamma(2,1)$ variable.

The construction of the PDF of $XY$ from that of a $U(0,1)$ distribution is shown from left to right, proceeding from the uniform, to the exponential, to the $\Gamma(2,1)$, to the exponential of its negative, to the same thing scaled by $20$, and finally the symmetrized version of that. Its PDF is infinite at $0$, confirming the discontinuity there.

We might be content to stop here. For instance, this characterization gives us a way to generate realizations of $XY$ directly, as in this R expression:

n <- 1; 20 * exp(-rgamma(n, 2, scale=1)) * ifelse(runif(n) < 1/2, -1, 1)


Thsis analysis also reveals why the pdf blows up at $0$. That singularity first appeared when we considered the exponential of (the negative of) a $\Gamma(2,1)$ distribution, corresponding to multiplying one $U(0,1)$ variate by another one. Values within (say) $\varepsilon$ of $0$ arise in many ways, including (but not limited to) when (a) one of the factors is less than $\varepsilon$ or (b) both the factors are less than $\sqrt{\varepsilon}$. That square root is enormously larger than $\varepsilon$ itself when $\varepsilon$ is close to $0$. This forces a lot of probability, in an amount greater than $\sqrt{\varepsilon}$, to be squeezed into an interval of length $\varepsilon$. For this to be possible, the density of the product has to become arbitrarily large at $0$. The subsequent manipulations--rescaling by a factor of $20$ and symmetrizing--obviously will not eliminate that singularity.

This descriptive characterization of the answer also leads directly to formulas with a minimum of fuss, showing it is complete and rigorous. For instance, to obtain the pdf of $XY$, begin with the probability element of a $\Gamma(2,1)$ distribution,

$$f(t)dt = te^{-t}dt,\ 0 \lt t \lt \infty.$$

Letting $t=-\log(z)$ implies $dt = -d(\log(z)) = -dz/z$ and $0 \lt z \lt 1$. This transformation also reverses the order: larger values of $t$ lead to smaller values of $z$. For this reason we must negate the result after the substitution, giving

$$f(t)dt = -\left(-\log(z) e^{-(-\log(z))} (-dz/z)\right) = -\log(z) dz,\ 0 \lt z \lt 1.$$

The scale factor of $20$ converts this to

$$-\log(z/20) d(z/20) = -\frac{1}{20}\log(z/20)dz,\ 0 \lt z \lt 20.$$

Finally, the symmetrization replaces $z$ by $|z|$, allows its values to range now from $-20$ to $20$, and divides the pdf by $2$ to spread the total probability equally across the intervals $(-20,0)$ and $(0,20)$:

\eqalign{ f_{XY}(z)dz &= -\frac{1}{2}\frac{1}{20} \log(|z|/20),\ -20 \lt z\lt 20;\\ f_{XY}(z)dz &= 0\ \text{otherwise}. }

• Thank you for trying to make it more "approachable. I was still finding this a bit counter intuitive so I just executed this (similar to Xi'an's "simulation"): plot( density( outer(seq(-10,10,length=10),seq(0,2,length=10), "*") ) ) Cranking the length up to 100 avoids some of the artifacts for densities on bounded distributions.
– DWin
Jan 25, 2015 at 21:48

In your derivation, you do not use the density of $X$. Since $X\sim\mathcal{U}(0,2)$, $$f_X(x) = \frac{1}{2}\mathbb{I}_{(0,2)}(x)$$so in your convolution formula $$h(v)= \frac{1}{20} \int_{-10}^{10} \frac{1}{|y|}\cdot \frac{1}{2}\mathbb{I}_{(0,2)}(v/y)\text{d}y$$(I also corrected the Jacobian by adding the absolute value). Hence, \begin{align*} h(v) &= \frac{1}{40} \int_{-10}^{0} \frac{1}{|y|} \mathbb{I}_{0\le v/y\le 2}\text{d}y+\frac{1}{40} \int_{0}^{10} \frac{1}{|y|}\mathbb{I}_{0\le v/y\le 2}\text{d}y\\ &= \frac{1}{40} \int_{-10}^{0} \frac{1}{|y|} \mathbb{I}_{0\ge v/2\ge y\ge -10}\text{d}y+\frac{1}{40} \int_{0}^{10} \frac{1}{|y|}\mathbb{I}_{0\le v/2\le y\le 10}\text{d}y\\&= \frac{1}{40} \mathbb{I}_{-20\le v\le 0} \int_{-10}^{v/2} \frac{1}{|y|}\text{d}y+\frac{1}{40} \mathbb{I}_{20\ge v\ge 0} \int_{v/2}^{10} \frac{1}{|y|}\text{d}y\\ &= \frac{1}{40} \mathbb{I}_{-20\le v\le 0} \log\{20/|v|\}+\frac{1}{40} \mathbb{I}_{0\le v\le 20} \log\{20/|v|\}\\ &=\frac{\log\{20/|v|\}}{40}\mathbb{I}_{-20\le v\le 20} \end{align*} Here is a confirmation by simulation of the result:

obtained as

   hist(runif(10^6,0,2)*runif(10^6,10,10),prob=TRUE,
nclass=789,border=FALSE,col="wheat",xlab="",main="")

• The answer looks correct, cgo. Note that when $-20\lt v \lt 20$, $\log(20/|v|)$ is positive because $20/|v|\gt 1$. The plot shows the graph and clearly it is positive throughout the domain pictured. An equivalent expression is $-\log(|v|/20)$, which is the one I chose to use in my answer.