What is the new probability density function by generating a random number by taking the reciprocal of a uniformly random number between 0 and 1?
Solution 1:
Let the old probability density function be $f_1(x)$, and the new one be $f_2(x)$.
We have:$$ \int_1^af_2(x)\mathrm dx=\int_\frac1a^1f_1(x)\mathrm dx $$where $a>1$.
We also know that $f_1(x)$ is uniform, and spans from $0$ to $1$. Therefore, $f_1(x)=1$ in that interval.
Therefore:$$ \int_1^af_2(x)\mathrm dx=\int_\frac1a^1\mathrm dx=1-\frac1a $$
Differentiating both sides with respect to $a$:$$ \frac{\mathrm d}{\mathrm da}\int_1^af_2(x)\mathrm dx=\frac{\mathrm d}{\mathrm da}\left(1-\frac1a\right) $$
Simplifying both sides:$$ f_2(a)=\frac1{a^2} $$ $\blacksquare$
Solution 2:
Denote with $U$ the random number you generate, then $U\sim U(0,1)$ and you want to determine the distribution of $Y=\frac{1}U$. So, for $1\le y<+\infty$, you have that $$F_{Y}(y)=P(Y\le y)=P(1/U\le y)=P(U\ge 1/y)=1-P(U<1/y)=1-F_U(1/y)$$ Hence $$f_Y(y)=\frac{d}{dy}F_Y(y)=\frac{d}{dy}\left(1-F_U(1/y)\right)=\frac1{y^2}f_U(1/y)=\frac1{y^2}\cdot1=\frac1{y^2}\mathbf{1_{y\ge1}}$$