help-octave
[Top][All Lists]
Advanced

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

Re: An example of poor C++ performance


From: Paul Kienzle
Subject: Re: An example of poor C++ performance
Date: Wed, 23 Feb 2005 23:39:17 -0500

The docs say he is using Box-Muller for normal random numbers, which
uses sqrt(-2*log(z)/z) and four multiplies for each pair of numbers.

Marsaglia's ziggurat algorithm (see randmtzig.c in octave-forge) uses
a table lookup, a multiply and a couple of integer ops each cycle.

The rejection rate of ziggurat is around 0.7%, compared to
Box-Muller's 21.5%

Ziggurat will be faster.

x86 ziggurat vs. uniform generator:

  octave>  tic; randn(1000000,1); toc
  ans = 0.38682
  octave>  tic; rand(1000000,1); toc
  ans = 0.31365

PPC ziggurat vs. uniform generator:

  octave> tic; randn(1000000,1); toc
  ans = 0.30067
  octave> tic; rand(1000000,1); toc
  ans = 0.16355


- Paul

On Feb 23, 2005, at 6:08 PM, Steve C. Thompson wrote:

Has anyone had experience using generators from this page:

http://www.agner.org/random/



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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