Simulating from this density? How can I simulate from the density $f(x)=x^2\phi(x)$? Where $\phi$ is the standard normal density. Preferably directly, without using MCMC.
 A: [The cdf of this variable is $\Phi(x)-x\phi(x)$ but that's not likely to yield a convenient way to generate via the inverse-cdf method.]
Transformation is fairly easy -- if $X$ has the specified density, then  $Y=\frac12 X^2$ has a simple, well-known distribution that is often available in statistical computing environments already (it is in R for example; it should also be available in many libraries)
If you're unfamiliar with transforming random variables, it's covered in detail in many places - see here for example, or here, and in this question CDF of transformed random variable; the calculations are straightforward substitution in a formula and one very simple differentiation. There's a detailed (and related) example discussed here.
So if you can generate from the appropriate distribution for $Y$, then $X=Z\sqrt{2Y}$ (where $Z$ is a random sign, ie. $\pm 1$ with equal probability) will have the distribution you're after.
(Actually the factor of $2$ could be incorporated in the original generation by changing the scale parameter, which may be slightly more convenient, avoiding the need to double $Y$ before taking the square root - because it would have been doubled at the previous stage)
We can see that this method works; here's a histogram of a large sample generated using this approach, and the functional form of the density you specified drawn over the top:

While this is very convenient, if efficiency is an issue it's not likely to be faster than a well-chosen variant of the accept-reject method (ratio-of uniforms counts as one possible variant of accept-reject; it might be suitable particularly if accompanied by its own transformation -- in particular, one not requiring a square root, in the interests of speed)
