Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Let XX have density fXf_X. As you have seen, the random variable Y=X2Y = X^2 comes up frequently in calculations. Thus far, all we have needed is E(Y)E(Y) which can be found by the formula for the expectation of a non-linear function of XX. To find the density of YY, we can’t directly use the change of variable formula of the previous section because the function g(x)=x2g(x) = x^2 is not monotone. It is two-to-one because both x\sqrt{x} and x-\sqrt{x} have the same square.

In this section we will find the density of YY by developing a modification of the change of variable formula for the density of a monotone function of XX. The modification extends in a straightforward manner to other two-to-one functions and also to many-to-one functions.

16.4.1Density of Y=X2Y = X^2

If XX can take both positive and negative values, we have to account for the fact that there can be two mutually exclusive ways in which the event {Ydy}\{ Y \in dy \} can happen: either XX has to be near the positive square root of yy or near the negative square root of yy.

<Figure size 432x288 with 1 Axes>

So the density of YY at yy has two components, as follows. For y>0y > 0,

fY(y) = a+bf_Y(y) ~ = ~ a + b

where

a=fX(x1)2x1    at x1=ya = \frac{f_X(x_1)}{2x_1} ~~~~ \text{at } x_1 = \sqrt{y}

and

b=fX(x2)2x2    at x2=yb = \frac{f_X(x_2)}{\vert 2x_2 \vert} ~~~~ \text{at } x_2 = -\sqrt{y}

We have used g(x)=2xg'(x) = 2x when g(x)=x2g(x) = x^2.

For a more formal approach, start with the cdf of YY:

FY(y) = P(Yy)= P(Xy)= P(yXy)= FX(y)FX(y)\begin{align*} F_Y(y) ~ &= ~ P(Y \le y) \\ &= ~ P(\vert X \vert \le \sqrt{y}) \\ &= ~ P(-\sqrt{y} \le X \le \sqrt{y}) \\ &= ~ F_X(\sqrt{y}) - F_X(-\sqrt{y}) \end{align*}

Differentiate both sides to get our formula for fY(y)f_Y(y); keep an eye on the two minus signs in the second term and make sure you combine them correctly.

This approach can be extended to any many-to-one function gg. For every yy, there will be one component for each value of xx such that g(x)=yg(x) = y.

16.4.2Square of the Standard Normal

Let ZZ be standard normal and let W=Z2W = Z^2. The possible values of WW are non-negative. For a possible value w0w \ge 0, the formula we have derived says that the density of WW is given by:

fW(w) = fZ(w)2w + fZ(w)2w= 12πe12w2w + 12πe12w2w=12πw12e12w\begin{align*} f_W(w) ~ &= ~ \frac{f_Z(\sqrt{w})}{2\sqrt{w}} ~ + ~ \frac{f_Z(-\sqrt{w})}{2\sqrt{w}} \\ \\ &= ~ \frac{\frac{1}{\sqrt{2\pi}} e^{-\frac{1}{2}w}}{2\sqrt{w}} ~ + ~ \frac{\frac{1}{\sqrt{2\pi}} e^{-\frac{1}{2}w}}{2\sqrt{w}} \\ \\ &= \frac{1}{\sqrt{2\pi}} w^{-\frac{1}{2}} e^{-\frac{1}{2}w} \end{align*}

By algebra, the density can be written in an equivalent form that we will use more frequently.

fW(w) = 1212πw121e12wf_W(w) ~ = ~ \frac{\frac{1}{2}^{\frac{1}{2}}}{\sqrt{\pi}} w^{\frac{1}{2} - 1} e^{-\frac{1}{2}w}

This is a member of the family of gamma densities that we will study later in the course. In statistics, it is called the chi squared density with one degree of freedom.