4 ms·
I implemented Marsaglia's Box Muller method in a library (^) and it seems quite quick. It doesn't involve trig functions, just a sqrt, a log, and an average of
by strainer 8y ago
I implemented Marsaglia's Box Muller method in a library (^) and it seems quite quick. It doesn't involve trig functions, just a sqrt, a log, and an average of about two rands per normal outputted.
It seems to work out around the same speed as a trig function - in javascript.
For some purposes just averaging a few rands could be used to get a good enough approximation of a normal.
I wonder if a short Taylor series could be mined that could quite accurately map equal to gaussian distribution.
[^]http://strainer.github.io/Fdrandom.js/ http://strainer.github.io/Fdrandom.js/