# Distribution of Functions of Random Variables

In general, how would one find the distribution of $f(X)$ where $X$ is a random variable? Or consider the inverse problem of finding the distribution of $X$ given the distribution of $f(X)$. For example, what is the distribution of $\max(X_1, X_2, X_3)$ if $X_1, X_2$ and $X_3$ have the same distribution? Likewise, if one is given the distribution of $Y = \log X$, then the distribution of $X$ is deduced by looking at $\text{exp}(Y)$?

-
By... finding it? There isn't really a magic wand you can wave here. – Qiaochu Yuan Oct 23 '10 at 19:43
So suppose you are given log(X)~N(2,4). How do you find distribution of X? It would be X~N(e^2, e^2) where the second term is the variance? – PEV Oct 23 '10 at 19:45
Trevor: if $\log(X)$ is normally distributed, $X$ itself will not be normally distributed at all. (For instance, we must have $X>0$ almost surely.) Instead, it has a so-called log-normal distribution. See en.wikipedia.org/wiki/Log-normal_distribution – Nate Eldredge Oct 23 '10 at 20:27
@Nate: Who is Trevor? – Did Jun 4 '11 at 17:11
@Didier: Perhaps a former username of PEV? – Nate Eldredge Jun 4 '11 at 17:39

## 4 Answers

Qiaochu is right. There isn't a magic wand. That said, there is a set of common procedures that can be applied to certain kinds of transformations. One of the most important is the cdf (cumulative distribution function) method that you are already aware of. (It's the one used in your previous question.) Another is to do a change of variables, which is like the method of substitution for evaluating integrals. You can see that procedure and others for handling some of the more common types of transformations at this web site. (Some of the other examples there include finding maxes and mins, sums, convolutions, and linear transformations.)

-
The web site mentioned now seems to be available under math.uah.edu/stat/dist/Transformations.html. – Felix Z. Hoffmann May 23 '13 at 12:16

You can use the law of conditional probability:

$P(A)=\int^{\infty}_{-\infty}P(A|B)f(B)$

So in your case, for a random variable $X\in[0,1)$:

$P(x>f(X))=\int^{\infty}_{-\infty}[x>f(a)][0<a<1]da=\int^{1}_{0}[x>f(a)]da$

Where the brackets are Iverson brackets.

Example, the distribution for a random variable $X\in[0,1)$ squared:

$P(x>X^2)=\int^{1}_{0}[x>a^2]da=\int^{1}_{0}[\sqrt{x}>a]da=\int^{\sqrt{x}}_{0}1da=\sqrt{x}$

Assuming $x\in[0,1]$. The pdf is then $\frac{d\sqrt{x}}{dx}=\frac{1}{2\sqrt{x}}$.

-

If $f$ is a monotone and differentiable function, then the density of $Y = f(X)$ is given by

$$p_{Y}(y) = \left| \frac{1}{f'(f^{-1}(y))} \right| \cdot p_X(f^{-1}(y))$$

where $p_X$ is the density of $X$.

-
For the record, this is what I meant by doing a change of variables. (See formulas 5 and 6 in the site linked to in my answer.) Still, this is an important special case, and the formula deserves to be mentioned explicitly, so +1. – Mike Spivey Jun 4 '11 at 18:01

Let me take the risk of mitigating Qiaochu's healthy skepticism and mention that a wand I find often quite useful to wave is explained on this page. There, I argue that: The simplest and surest way to compute the distribution density or probability of a random variable is often to compute the means of functions of this random variable.

For example, the fact that $Y=\log X$ is normal $N(2,4)$ is equivalent to the fact that, for every bounded measurable function $g$, $$\mathrm E(g(Y))=\int g(y) f_Y(y)\mathrm{d}y,$$ for a density $f_Y$ everybody knows and whose precise form will not interest us. Likewise, the fact that the distribution $X$ has density $f_X$ is equivalent to the fact that, for every bounded measurable function $g$, $$\mathrm E(g(X))=\int g(x) f_X(x)\mathrm{d}x.$$ Hence our task is simply to pass from one formula to the other. But this is easy since $g(X)=g(\mathrm{e}^Y)$ is also a function of $Y$. As such, $$\mathrm E(g(X))=\int g(\mathrm{e}^y) f_Y(y)\mathrm{d}y,$$ and our task is to solve for $f_X$ the equations $$\int g(x) f_X(x)\mathrm{d}x=\int g(\mathrm{e}^y) f_Y(y)\mathrm{d}y,$$ We have no choice for our next step but to use the change of variable $x\leftarrow \mathrm{e}^y$. That is, $y\leftarrow \log x$ and $\mathrm{d}y=x^{-1}\mathrm{d}x$, which yields $$\int g(\mathrm{e}^y) f_Y(y)\mathrm{d}y=\int g(x) f_Y(\log x)x^{-1}\mathrm{d}x.$$ By identification, $f_X(x)=f_Y(\log x)x^{-1}$.

In a nutshell the idea is that the very notations of integration help us to get the result and that during the proof we have no choice but to use the right path. We leave as an exercise the computation of the density of each random variable $Z=\varphi(Y)$, for some regular enough function $\varphi$.

Note that maxima and minima of independent random variables should be dealt with by a specific, different, method, explained on this page.

-