[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-gsl] Speed of Ziggurat Compared With Box Muller on Visual Studio 2

From: Simon Manning
Subject: [Help-gsl] Speed of Ziggurat Compared With Box Muller on Visual Studio 2005
Date: Wed, 5 Dec 2007 18:10:04 +0000

I need to generate random numbers drawn from a standard Gaussian
distribution. From a search on the internet the ziggurat method appears to
be the method of choice, so I thought that I would try the GSL version. I
have run some simple timing tests comparing gsl_ran_ugaussian and
gsl_ran_gaussian_ziggurat. Calling these functions from C++ compiled with MS
Visual Studio 2005 I get, for example:

Timings for 100000000 draws.
Time for GSL Box-Muller with MT: 13.329   [gsl_ran_ugaussian with
Time for GSL ziggurat with minstd: 7.562   [gsl_ran_gaussian_ziggurat with
Time for GSL ziggurat with MT: 7.625        [gsl_ran_gaussian_ziggurat with

In each case I am simply timing the for loop

for (i = 0; i < numDraws; ++i) {
        double x = gsl_ran_gaussian_ziggurat(r, 1.0);

and the same for gsl_ran_ugaussian.

Ziggurat is approximately twice as fast as Box-Muller, but according to it should be almost 4 times as fast.

Therefore, my question is this: is there a problem with my build, or how I
am using GSL, or is the GSL ziggurat really only twice as fast as the


Simon Manning.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]