Why are absolute values involved in functions of random variables?

From a textbook:

If $X$ is a continuous random variable, then so too is the new random variable $Y = Y (X)$. The probability that $Y$ lies in the range $y$ to $y + dy$ is given by $$g(y)=\int_{dS}f(x)dx,$$ where $dS$ corresponds to all values of $x$ for which $Y$ lies in the range $y$ to $y +dy$. The simplest case occurs when $Y (X)$ possesses a single-valued inverse $X(Y)$. In this case, we may write $$g(y)dy=\lvert\int_{x(y)}^{x(y+dy)}f(x')dx'\rvert=\int_{x(y)}^{x(y)+\lvert \frac{dx}{dy}\lvert dy}f(x')dx',$$ from which we obtain $$g(y)=f(x(y))\lvert\ \frac{dx}{dy} \lvert.$$

What I know:

1. For this case, $x$ and $y$ has one to one correspondence, ie for each value of $x$, $Y(x)$ gives a unique value of $y$. Similarly $X(y)$ give unique $x$.
2. What the integral does is to integrate a range of infinitesimal probability $f(x)$. That range is all $x$ that gives that particular value of $y$ by $Y(x)$.

What I don't know:

1. Why is the integral needed to be "absoluted"? I think $f(x)$ is always positive because it is a probability distribution and by definition $0\le f(x)\le 1$, so there is no need to make sure the integral gives non-negative values.
2. How is the absolute sign moved to the upper limit of the integral?
3. How to evaluate the equation to give the final result? I think the text just divide the whole equation by $dy$ to give the final result and ignore what happens to the lower and upper limit of the integral. Again I don't how the absolute sign appears.

Attempts to answer: I searched wikipedia and google and found several online lecture notes. None of them explained the source of the absolute sign.

• "If $X$ is a continuous random variable, then so too is the new random variable $Y = Y (X)$." Actually, no, and it is direct to find continuous random variables $X$ and functions $f$ such that $f(X)$ is not continuous. – Did Jul 2 '16 at 12:41

Find a graph of the normal distribution function. Compare the left half as a PDF and the right half as PDF. (Each half is monotone, so each half is invertible.) Pick a narrow range of $y$ values; there will be $x$s in each half that contribute mass to the PDF in terms of $y$. It doesn't matter whether the derivative is positive or negative, they contribute positive mass.

Now the integral you have has the derivative appearing at one endpoint. You think of it as the upper endpoint, but that is only true if the derivative is positive. If the derivative is negative, your endpoints of integration are reversed and the result of the integral is negative. One way to correct this is to take the absolute value of the integral -- you don't care whether the PDF in $x$ was increasing or decreasing, you only care how widely it was distributing mass among the $y$s. This is an answer to your question 1.

For your question 2, again we only care about the magnitude of the slope (how rapidly we move through the $y$s receiving mass for each unit of $x$). Further, we may consider the linear approximation (in particular, by Taylor series: $x(y + \mathrm{d}y) \approx x(y) + \dfrac{\mathrm{d}x}{\mathrm{d}y} \mathrm{d}y$) as running from the upper bound of integration down or from the lower bound of integration up. If your derivative is negative, swap the order of the endpoints and switch from which endpoint the linear approximation proceeds. This will give you the absolute value on the derivative.

The fundamental theorem of calculus with the chain rule is the answer to your third question. (The upper endpoint is moving $\left| \dfrac{\mathrm{d}x}{\mathrm{d}y} \right|$-times as fast as $\mathrm{d}y$, which constant pops out by the chain rule.)

Sorry, I'm on a smartphone so I'll answer shortly.

1) $f>0$ but $x(y)$ could decrease, the integral must be taken from the lowest $x$ so, using the absolute value, you are just swapping the integration limits.

2) same as above, but we don't swap the limits but force the upper limit to be greater than the lower (here we abuse the $dx$ smallness).

3) suppose you know the primitive, the integral is a difference that, for $dx$ going to $0$, becomes again the $f$ function.

• Downvoter please explain what do you think my answer is missing. – N74 Jul 2 '16 at 13:11