I have learned that for monotonic functions, one can obtain the formula for the pdf of a random variable, by using the following:
$$f_Y(y) = \left| \frac{dx}{dy}\right|f_X(x)$$ where $x$ is $g^{-1}(y)$ and $Y=g(X)$
Then I have the following in my notes: "the most general equation for change of variables (includes non-monotonic functions)":
$$f_Y(y) = \int_{-\infty}^{+\infty}\delta (g(x)-y)f_X(x)dx$$
I am not quite sure where that formula comes from, and why it holds. And how would I evaluate it... Do you have some examples perhaps? I don't know how I would evaluate that integral. I know that:
$$\int_{-\infty}^{+\infty}\delta (x-x_0) dx=1$$
and that
$$\int_{-\infty}^{+\infty}g(x) \delta(x-x_0) dx=g(x_0)$$