Thread overview
Re: Normal/Gaussian random number generation for D
Dec 24, 2012
bearophile
Dec 25, 2012
bearophile
October 23, 2012
On 10/22/2012 04:45 PM, Joseph Rushton Wakeling wrote:
> A request for feedback on the design of this code before I put it through some
> serious testing and submit a formal pull request to Phobos' std.random.

One testing note -- this code compiles with the latest from-GitHub dmd, but not with the latest ldc, which exits with the following error:

--------------------------------------------------------------------------------
normal.d(110): Error: constructor normal.Normal!().Normal.this (real m, real s) is not callable using argument types (MersenneTwisterEngine!(uint,32,624,397,31,-1727483681u,11,7,-1658038656u,15,-272236544u,18))
normal.d(110): Error: expected 2 function arguments, not 1
--------------------------------------------------------------------------------

I haven't yet tested with latest gdc as I don't have a working from-source build, but compiling with gdc 4.6.3 gives:

--------------------------------------------------------------------------------
normal.d:28: Error: template instance template 'isUniformRNG' is not defined
normal.d:89: Error: template instance Normal!() does not match template declaration Normal(T = real,alias NormalRandomNumberEngine = NormalBoxMullerEngine,UniformRandomNumberGenerator = Random) if (isFloatingPoint!(T) && isUniformRNG!(UniformRandomNumberGenerator))
--------------------------------------------------------------------------------

December 24, 2012
Hello all,

Just to note that following some very productive code exchanges and discussion with Jerro, this has now been submitted to Phobos:
https://github.com/D-Programming-Language/phobos/pull/1029

Do let us have your feedback!

Best wishes (and Merry Xmas),

     -- Joe
December 24, 2012
Joseph Rushton Wakeling:

> https://github.com/D-Programming-Language/phobos/pull/1029

Regarding uniform01:
http://d.puremagic.com/issues/show_bug.cgi?id=5240

isPowerOfTwo() (or shorter isPow2()) is desired in Phobos.

Bye,
bearophile
December 25, 2012
On 12/24/2012 09:24 PM, bearophile wrote:
> Regarding uniform01:
> http://d.puremagic.com/issues/show_bug.cgi?id=5240

OK.

> isPowerOfTwo() (or shorter isPow2()) is desired in Phobos.

Where would you like to see it placed?  std.math?
December 25, 2012
Joseph Rushton Wakeling:

> Where would you like to see it placed?  std.math?

In Phobos there is also the std.bitmanip module, but for iLog2, isPow2, and few other bithacks std.math seems a better place:

http://graphics.stanford.edu/~seander/bithacks.html

Bye,
bearophile