# How to find the distribution of a function of two random variables?

I have the joint pdf

$$f(x_1,x_2)=\begin{cases}\frac{1}{4}\;,\ -1

I have to find the distribution of $$Y=\frac{X_2}{1+X_1^2}.$$

I have tried to take the transformation $$Y_1=\frac{X_2}{1+X_1^2}$$ and $$Y_2=1+X_1^2$$, but I am having problems understanding. Is this a good way to proceed? And what will be the range of the transformed variable? Can it be solved from these inequalities?

$$-1\lt \sqrt{Y_2-1}\lt 1\text{ and }-1\lt Y_1Y_2\lt 1$$

• Because $\Pr(Y\le y) = \Pr(X_2 \le y(1 + X_1^2)),$ draw a graph of this region in the $(X_1,X_2)$ plane for some values of $y.$ You might find it easier first to solve this problem for $f(x_1,x_2)=1$ for $0\le x_1,x_2\le 1.$
– whuber
Commented Jul 4, 2022 at 14:29

Often, the most straightforward way to find the distribution of a variable defined in terms of other random variables is to compute its cumulative distribution function. For any number $$y$$ this function is the chance $$Y\le y,$$

$$F_Y(y) = \Pr(Y \le y) = \Pr\left(\frac{X_2}{1 + X_1^2}\le y\right) = \Pr(X_2 \le y(1 + X_1^2)).\tag{*}$$

It helps, as you suggest, to know what the "interesting" range of values of $$y$$ might be. Two standard methods to find (or estimate) that range are

1. Use mathematical facts about inequalities and the possible values of the original random variables $$(X_1, X_2)$$. For instance, because $$1+X_1^2 \ge 1,$$ necessarily $$|Y| = \bigg| \frac{X_2}{1 + X_1^2} \bigg| \le |X_2| \le 1.$$ This tells us there is no chance that $$Y$$ is smaller than $$-1$$ and no chance it exceeds $$1.$$ Thus, we only have to examine the possible values $$-1 \le y \le 1.$$

2. Simulate some values. Here, for instance, is a straightforward simulation of a million values of $$Y$$ using R and a histogram showing the results:

n <- 1e6
X1 <- runif(n, -1, 1)
X2 <- runif(n, -1, 1)
Y <- X2 / (1 + X1^2)
hist(Y)


Again, we discover we only need to work with values of $$y$$ between $$-1$$ and $$1.$$

This reduces the problem to finding the chances of events of the form $$(*),$$ $$X_2 \le y(1 + X_1^2),$$ for $$-1\le y \le 1.$$

It helps to draw graphs of these events. They are bounded by contours of the function $$Y(X_1, X_2)$$ (which itself is defined only on the square shown here):

This enables you immediately to see the shapes of all these events. That is because the event $$Y \le y$$ is comprised by all contours of the form $$Y=y_0$$ for $$-1 \le y_0 \le y.$$ In the plot, such an event will have one contour for its bound along with the region below that contour.

You can see there are four different shapes, as typified by these regions of the form $$Y \le y:$$

The boundaries of these shapes are pieces of horizontal and vertical lines, along with a piece of a parabola.

Now, in general, you need to integrate the density function of $$(X_1,X_2)$$ over any such shape. But that's easy here, because that density is a constant $$1/4:$$ that is, the probability of any event is one-quarter its area. So, use elementary Calculus to find the areas of these shapes: that will be your answer.

Finally, if you wish to find the density function of $$Y,$$ just differentiate $$F_Y$$ (as usual). This is perhaps the hardest part of the problem, because it requires you to know several rules of differentiation--and it doesn't advance your understanding of the important concepts in this problem--so try to avoid this step if you can.