# Mapping a PDF to a uniform distribution on $(0,1)$

Let me preface this by saying that I'm not familiar with differential equations, other than basic "separable" differential equations. This problem has come up in a Probability problem that I am doing.

Consider a random variable $X$ with the PDF given by $$f(x) = \dfrac{x-1}{2}\text{, } x \in (1, 3)$$ and $0$ elsewhere. I am asked to find a monotonic transformation $Y = u(X)$ such that $Y$ is uniformly distributed in $(0, 1)$.

I am wondering about a more explicit way to attempt this problem, rather than trial-and-error.

By the Method of Transformations (if we further assume that $u^{-1}$ is differentiable), I know that $$f_Y(y) = f_X(u^{-1}(y))\left|\dfrac{\text{d}}{\text{d}y}[u^{-1}(y)] \right| = \dfrac{u^{-1}(y)-1}{2}\cdot\left|\dfrac{\text{d}}{\text{d}y}[u^{-1}(y)] \right| = 1\text{.}$$

If we assume that the derivative of $u^{-1}$ is always positive, setting $h = u^{-1}$, we have the differential equation $$(h-1)h^{\prime} = 2\text{.}$$

WolframAlpha tells me this is a first-order non-linear differential equation, with solutions \begin{align} h(y) &= 1-\sqrt{c_1+4y+1}\\ h(y) &= 1+\sqrt{c_1+4y+1}\text{.} \end{align} Which one do I choose? Also, does it matter what initial condition I impose on this?

A variant of this problem comes up a lot when you're trying to simulate something using a Monte Carlo code. Here's how I would obtain $u(x)$, and it doesn't require the solution of any differential equations:

The CDF $F(x)$ is given by

$$F(x) = \int_1^x f(w) dw = \frac{(x-1)^2}{4}$$

$F(x)$ is uniformly distributed between 0 and 1 (my wording here may not be correct, but basically it runs from 0 to 1) for $x \in (1,3)$. If we set this equal to $y$, then we obtain:

$$y = \frac{(x-1)^2}{4}$$

Thus, we can just simply choose

$$u(x) = F(x) = \frac{(x-1)^2}{4}$$

• However, in my experience, the more useful result is usually $u^{-1}(x)$, which is given by: $u^{-1}(y) = \sqrt{4y}+1$. I think you were kind of getting at this with your differential equation stuff -- this matches $h(y) = 1 + \sqrt{c_1 + 4y + 1}$ with $c_1 = -1$. The reason $u^{-1}$ is useful is because computer codes generally have a function that generates uniformly distributed numbers between (0,1) -- i.e., computers can generate $y$ easily. But, if you want $x$, you need a function that maps $y$ to $x$. That function is $u^{-1}$. Jul 19, 2016 at 20:14
• OH, I see what you did - so you exploited the fact that $F(X)$ is uniformly distributed in $(0, 1)$. Clever! Jul 19, 2016 at 20:15
• Yep! From the wording of your problem, however, it sounds like you may be more interested in $u^{-1}$. (It's weird that they don't just ask you for a CDF.) See the comment above for my thoughts on it. Jul 19, 2016 at 20:16

The easy way for this problem, as is the case for many pdf problems, is to work with CDF's instead. Here, since $f(x) = \frac{x-1}{2}$ on $(1,3)$, $$F(x) = \left\{ \array{0 & x\leq1\\ \frac{(x-1)^2}{4} & 1< x < 3 \\ 1 & x\geq 3 }\right.$$ And this needs to match the CDF of the uniform distribution ojn $(0,1)$ $$F(y) = y$$

So $$y= \frac{(x-1)^2}{4} \implies x = 1+\sqrt{4y}$$ and this is the needed transformation.

$$(h-1)h'=2$$ is a separable differential equation: it can be simply re-written as $$\frac{d}{dt}\left(\frac{h^2}{2}-h\right) = 2$$ from which: $$(h-1)^2=(4t+C)$$ and $$h = 1\pm\sqrt{C+4t}$$ readily follow. Have also a look at the generating function for Catalan numbers.