Opened 15 years ago

Closed 9 years ago

#1437 closed Patches (wontfix)

normal_distribution.hpp, improvements to distribution and possibly speed

Reported by: m.bannerman@… Owned by: No-Maintainer
Milestone: To Be Determined Component: random
Version: Boost 1.34.1 Severity: Optimization
Keywords: random normal distribution box muller transform gaussian Cc:

Description

Hello, I have adapted the current normal_distribution from the polar form to the outward Cartesian form. See here http://web.mat.bham.ac.uk/marijke/bm/yabm.pdf listing the benefits of the Cartesian form for the distribution of numbers. This also eliminates trigonometric function calls, however, it does reject pairs of random numbers. Most websites (wolfram, wikipedia) state that the inward Cartesian form is faster but this is generator speed dependent.

I've found with my tests (mt19937, double datatype, gcc (GCC) 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2), -O2) its about 1.5x slower than the polar form. Although with faster generators I expect it to outperform the polar version.

I think this is an improvement on the current normal_distribution.hpp in time critical situations (if a fast generator is used) and it gives a better distribution of numbers, (points rather than bands of inaccessible numbers). I have also found that this version doesn't produce the "may be used uninitialised" warning when compiling with optimisations that I get when I use the original.

Posted to boost.developers 2007-11-11

Attachments (1)

normal_distribution.hpp (3.2 KB ) - added by m.bannerman@… 15 years ago.
Improved normal_distribution.hpp

Download all attachments as: .zip

Change History (4)

by m.bannerman@…, 15 years ago

Attachment: normal_distribution.hpp added

Improved normal_distribution.hpp

comment:1 by m.bannerman@…, 15 years ago

I forgot to mention that this also has a smaller memory footprint than the previous version.

comment:2 by Marshall Clow, 15 years ago

Owner: set to No-Maintainer

comment:3 by Steven Watanabe, 9 years ago

Resolution: wontfix
Status: newclosed

I've completely re-written normal_distribution since this ticket was created.

Note: See TracTickets for help on using tickets.