[SciPy-dev] Box-Muller considered slow.

Charles R Harris charlesr.harris at gmail.com
Thu Dec 8 17:33:07 CST 2005


On 12/8/05, David M. Cooke <cookedm at physics.mcmaster.ca> wrote:
>
> Charles R Harris <charlesr.harris at gmail.com> writes:
>
> > I have done some benchmarking of the ziggurat algorithm vs the
> Box-Muller
> > algorithm in boost/random for computing gaussian random variables. The
> ziggurat
> > method was 6x faster. As scipy at this time uses the Box-Muller method,
> I would
> > like to propose a switch to the ziggurat method.
>
> boost/random looks like it uses a deterministic polar method for
> gaussian RVs (at least in 1.33).


That's the Box-Muller algorithm.

I've had a look at the ziggurat algorithm; it's more complicated, so
> we'd need some code for it (hint, hint :-)


I've attached a templated version I use just to get some code out there. I
modified the original ziggurat method a bit to make it more straightforward.
I admit the code is not scipy compatible as it stands; in particular, my
default uniform doubles are thin and on the open interval (0,1).  If I get
some time I may make a genuine contribution ;)

How does one test the normal distribution ?

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-dev/attachments/20051208/46c5adbc/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: RandomNormal.h
Type: application/octet-stream
Size: 1593 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-dev/attachments/20051208/46c5adbc/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: RandomUniform.h
Type: application/octet-stream
Size: 1254 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-dev/attachments/20051208/46c5adbc/attachment-0001.obj 


More information about the Scipy-dev mailing list