Suppose $X \sim U(0,1)$, and $Y[x] = g(x)$ where $g(.)$ is some complicated function. I want to calculate/plot the density of $Y$. I can do this analytically for simple enough $g$.
I can also generate some large number $N$ samples of $X$ from the stardard uniform, calculate $y_i = Y(x_i)$ for each sample $x_i$, and then compute the histogram of these $ y_i, \forall i \in (1, ... N)$. This will turn out to be inefficient if, say the details of $p_Y(y)$ come from very small regions of $X$. Is there a better way to calculate/estimate $p_Y(y)$?