Normal/Gaussian random number generation for D

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Tue Oct 23 02:20:39 PDT 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))
--------------------------------------------------------------------------------



More information about the Digitalmars-d mailing list