How do you find the distribution of a function of a random variable?
Role: Data Scientist
Category: Statistics & Math
Difficulty: medium
Interview Round: Other
How do you find the distribution of a function of a random variable?
That is, given a random variable $X$ with a known distribution and a function $g$, how do you find the distribution of $Y = g(X)$? Describe the general method, the shortcuts, and when each one applies.
```hint Start from an event
Write the event $\{g(X) \le y\}$ as an event about $X$ alone, and see what you can compute from there.
```
```hint Watch the shape of g
Check what happens when $g$ is decreasing, and when two different values of $x$ map to the same $y$.
```
### What a Strong Answer Covers
- A general method that works for any $g$, with its steps
- The shortcut formula for a monotone, differentiable $g$, including why an absolute value appears
- How to handle a $g$ that is not one-to-one, and a discrete $X$
- At least one worked example carried through to a named distribution
- Cases where $Y$ has no density or a closed form is hard, and what to do then
### Follow-up Questions
- If $X \sim \text{Uniform}(0, 1)$, what is the distribution of $-\ln X$, and how is that result used to generate random numbers?
- How does the method change for a function of two random variables, such as $X_1 + X_2$ or $X_1 / X_2$?
- $X$ is standard normal and $Y = \max(X, 0)$. Does $Y$ have a density?
- How would you approximate the mean and variance of $g(X)$ when the exact distribution is hard to derive?
Overview: Asks how to derive the distribution of a transformed random variable from the known distribution of the original one. Tests the CDF method, the change-of-variables formula and its conditions, functions that are not one-to-one, discrete variables, and cases where no density exists.