Suppose for a random variable $X$ I have probability density function $f_{X}(x) = 4x^{3}$, for $0<x<1$, and $f_{X}(x) = 0$ otherwise. I'd like to find probability density function of random variable $Y = 2X-1$.
My solution: I simply rearrange the expression to get $X$ in terms of $Y$, i.e. $X = \frac{Y+1}{2}$. The range for $Y$ is $-1<Y<1$. Then I simply rewrite density function in terms of $y$ to get
$f_{Y}(y) = 4\left(\frac{y+1}{2}\right)^{3}, \qquad -1<y<1$,
and $f_{Y}(y) = 0$ otherwise.
However it turns out this is wrong, and we should have $f_{Y}(y) = 2\left(\frac{y+1}{2} \right)^{3}$, so basically my answer is wrong by a numerical factor (I have $4$ instead of $2$ ). Why does my approach of simply replacing the old variable in the formula for probability density function by the expression for the new variable in terms of old variable lead to an incorrect answer?
It's essentially because of the chain rule. If you look at the CDF, we have $\mathbb{P}(Y \le y) = \mathbb{P}(2X-1 \le y) = \mathbb{P}(X \le \frac{y+1}{2})$. Now we compute \begin{align*} f_Y(y) &= \frac{d}{dy} \mathbb{P}(Y \le y) \\ &= \frac{d}{dy} \mathbb{P}\left(X \le \frac{y+1}{2}\right) \\ &= \frac 12 f_X\left(\frac{y+1}{2}\right) \\ &= 2 \left(\frac{y+1}{2}\right)^3. \end{align*}