Hacker News new | ask | show | jobs
by bno1 883 days ago
Isn't inverse transform sampling even faster than ziggurat? Most languages have an approximate erf^-1 implementation, everything is straight forward from there. I needed to generate random numbers from a truncated normal distribution and found inverse transform sampling easier to implement than trying to understand and adapt the ziggurat algorithm.

A nice blog on this: https://stackedboxes.org/2017/05/01/acklams-normal-quantile-...

1 comments

Quite possibly. Iirc the benefit of ziggurat is that you get a "real" Gaussian with infinite tails in both directions vs inverse transform truncates it but it has been a very long time.