Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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?

share|improve this question
4  
Suprisingly, according to Wikipedia, the distribution is uniform between 0 and 1 and falls off quadratically after that. It doesn't look like something that would have a name. –  Rahul Jan 6 '12 at 18:59
2  
@Rahul Not really a name, but that is just a convex combination of the uniform $U[0,1]$ distribution and a Pareto distribution (with exponent $\alpha=1$). –  Srivatsan Jan 6 '12 at 19:15
    
Sorry, my comment was only considering the special case of a uniform distribution over $(0,1]$. –  Rahul Jan 6 '12 at 20:08
1  
The fact that in the case of $[0,1]$ the density of $Y/X$ is constant on $[0,1]$ is less surprising if you think of it this way: conditioning on any value $X = x \in (0,1]$, the part of the distribution of $Y/X$ on $[0,1]$ is uniform (corresponding to $Y$ in $[0,x]$). –  Robert Israel Jan 6 '12 at 20:47
    
@RahulNarain Curiously enough, for a simple model of semiconductor diode in which the current $I$ is related to the applied voltage $V$ as $I=e^V-1$ and $V$ having Laplacian pdf $\frac{1}{2}e^{-|x|}$, the pdf of $I$ is $$f(y) = \begin{cases}\frac{1}{2},& -1<y<0,\\ \frac{1}{2(y+1)^2}, & y \geq 0,\end{cases}$$ which is just a translated version of the density considered here. And no, it does not have a name among engineers either. –  Dilip Sarwate Jan 7 '12 at 2:31
add comment

2 Answers

If your interval is $(a,b)$, then look at the square $U=(a,b)\times(a,b)$. If $\frac{b}{a}\geq z\geq 1$, then the subspace of $U$ such that $x/y>z$ is just a lower right triangle of $U$ going from $(az,a)$ to $(b,a)$ to $(b,\frac{b}z)$. This has area equal to $\frac{(b-az)(\frac{b}z - a)}2 = \frac{(b-az)^2}{2z}$. So if $g(z)=p(x/y>z) = \frac{(b-az)^2}{2z(b-a)^2}$, then the distribution should be $-g'(z)$ for $z>1$.

This gives a distribution of $\frac{\frac{b^2}{z^2}-a^2}{2(b-a)^2}$ for $z\geq 1$.

For $\frac{a}{b}<z\leq 1$, we do a similar computation to show that:

$$p(\frac{x}{y}<z) = \frac{(bz-a)^2}{2z(b-a)^2}$$

The derivative gives us the distribution for these $z$, so the value is here is:

$$\frac{b^2-\frac{a^2}{z^2}}{2(b-a)^2}$$

So the result is: $$\frac{b^2-\frac{a^2}{z^2}}{2(b-a)^2}\text {when }\frac{a}b \leq z\leq 1$$ and $$\frac{\frac{b^2}{z^2}-a^2}{2(b-a)^2}\text{ when }1\leq z \leq \frac{b}a$$

share|improve this answer
add comment

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.

share|improve this answer
    
I corrected two minor mistakes near the end; the result is now in agreement with Thomas'. –  joriki Jan 6 '12 at 20:27
    
"almost surely"? Why not "surely"? –  TonyK Jan 6 '12 at 20:30
    
@TonyK I changed that. –  Sasha Jan 6 '12 at 20:39
    
@joriki Thank you for the edit. –  Sasha Jan 6 '12 at 20:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.