On 10/23/2012 03:50 PM, bearophile wrote:
Using the Boost API is useful. And using D-specific features/syntax is equally good.
Most of the existing std.random is based around the planned C++11 random API, which in turn derives from boost. There are several ways in which D seems able to do things more elegantly, however ... :-)
Using the Ziggurat algorithm is desired, otherwise people will have to implement it outside Phobos, because it's better if you have to generate many normal distributed values (and sometimes I need many of them). is it possible to have both algorithms? Maybe with a template argument?
Yes, that's exactly the plan. You see how there is an "engine" template argument (NormalRandomNumberEngine) which is currently by default Box-Muller, but could be Ziggurat or others (Marsaglia etc.) Other engines will be added later, Box-Muller is there as the first and easiest to implement.
The idea of a NormalRandomNumberEngine is that it is a struct which returns via opCall a number drawn from the distribution N(0, 1). This is trivial to transform into N(mean, sigma).