<s>[INST] What type of distribution would rand()/rand() produce? If rand() is a function which produces a linearly distributed random number over a range not containing zero, then what type of distribution would rand() / rand() produce?
I know it would center at 1, and there would be a few extreme values very close to zero or very large.
Does this type of random distribution have a name?
 [/INST] Let $U_1$ be a uniform random variable with domain $[a,b]$ for $b>a>0$, and let $U_2$ be another identically distributed independent uniform variable.
Let $X= \frac{U_1}{U_2}$. It is clear that $\frac{b}{a} \geqslant X \geqslant \frac{a}{b}$ with probability 1. Let $x$ be from such an interval. Then
$$ \begin{eqnarray}
 F(x) &=&  \mathbb{P}\left( X \leqslant x\right) = \mathbb{P}\left( U_1 \leqslant U_2 x \right) = \mathbb{E}\left( \min\left(1, \max\left(0,  \frac{x U_2 - a}{b-a}  \right) \right)  \right) \\
 & = &
  \int_0^1 \min\left(1, \max\left(0,  \frac{x (a+(b-a) u) - a}{b-a}  \right) \right) \mathrm{d} u \\
  &=& \int_0^1 \min\left(1, \max\left(0,  u \cdot x + \frac{a}{b-a} (x-1) \right) \right) \mathrm{d} u \\
  \end{eqnarray}
$$
Consider now two cases, $\frac{b}{a} \geqslant x \geqslant 1$ and $1 > x \geqslant \frac{a}{b}$.


*

*$\frac{b}{a} \geqslant x \geqslant 1$, which implies $u \cdot x + \frac{a}{b-a} (x-1) > 0$:


$$ 
\begin{eqnarray}
   F(x) &=& \int_0^1 \min\left(1, \max\left(0,  u \cdot x + \frac{a}{b-a} (x-1) \right) \right) \mathrm{d} u \\ 
   &=& \int_0^1 \min\left(1, u \cdot x + \frac{a}{b-a} (x-1) \right) \mathrm{d} u \\
   &=& \int_0^{u^\ast} \left( u \cdot x + \frac{a}{b-a} (x-1) \right) \mathrm{d} u + \int_{u^\ast}^1 \mathrm{d} u \\
   &=& \left(\frac{u^\ast}{2} x - \frac{b - a x}{ x(b-a)}\right) u^\ast + 1 \\
   &=& 1 - \frac{1}{2 x} \left( \frac{b-a x}{b-a} \right)^2 
\end{eqnarray}
$$
where $u^\ast$ solves $u x + \frac{a}{b-a} (x-1) = 1 $, i.e. $u^\ast = \frac{b-a x}{x (b-a)}$.


*

*$1 > x \geqslant \frac{a}{b}$ implies $u \cdot x + \frac{a}{b-a} (x-1) < 1$:
$$
\begin{eqnarray}
   F(x) &=& \int_0^1 \min\left(1, \max\left(0,  u \cdot x + \frac{a}{b-a} (x-1) \right) \right) \mathrm{d} u \\ 
  &=& \int_0^1 \max\left(0,  u \cdot x + \frac{a}{b-a} (x-1) \right) \mathrm{d} u \\
  &=& \int_{u_\ast}^1 \left(u \cdot x + \frac{a}{b-a} (x-1) \right) \mathrm{d} u \\
  &=& x \left( \frac{1}{2}- \frac{u_\ast^2}{2} \right) + \frac{a}{b-a} (x-1) \left( 1- u_\ast \right) \\
  &=& \frac{ (a- b x)^2}{2 (b-a)^2 x}
\end{eqnarray}
$$
where $u_\ast$ solves $ u \cdot x + \frac{a}{b-a} (x-1)  = 0$, i.e. $u_\ast = 
\frac{a}{b-a} \frac{1-x}{x}$.


Given $F(x)$ computed above, the probability density follows by differentiation.
</s>