The default engine, a reasonably collision free, with good statistical properties not easy to invert, and with a relatively small key (but not too small)
make the default random number generator type (a non threadsafe random number generator) easily available you can safely expect a new instance of this to be indipendent from all the others
default threadsafe random number generator type
Class that represents a random number generator. Normally you should get random numbers either with call-like interface: auto r=new Random(); r(i)(j)(k); or with randomize r.randomize(i); r.randomize(j); r.randomize(k); if you use this you should be able to easily switch distribution later, as all distributions support this interface, and can be built on the top of RandomG auto r2=r.NormalSource!(float)(); r2(i)(j)(k); there are utility methods within random for the cases in which you do not want to build a special distribution for just a few numbers
very simple statistal test, mean within maxOffset, and maximum/minimum at least minmax/maxmin
check a given generator both on the whole array, and on each element separately
shared locked (threadsafe) random number generator initialized with urandom if available, with time otherwise
if T is a float
Random number generators
This is an attempt at having a good flexible and easy to use random number generator. ease of use:
i=r.uniformR2(5,10); // uniform numbers in (5;10) f=r.uniformR2(5.0f,10.0f); rv=r.uniformR2(5.0L,10.0L); foreach (ref el;ar) el=r.uniformR2(5.0L,10.0L); // another way to do all the previous in one go: r.uniformR2D(5.0L,10.0L)(i)(f)(r)(ar); // uniform distribution -10..10 i=r.uniformRSymm(10); // well you get it... r.uniformRSymmD(10)(i)(f)(r)(ar); // any distribution can be stored auto r2=r.uniformRSymmD(10); // and used later r2(ar); // complex distributions (normal,exp,gamma) are produced for the requested type r.normalSource!(float)()(f); // with sigma=2 r.normalD(2.0f)(f); // and can be used also to initialize other types r.normalSource!(float)()(r)(ar); r.normalD(2.0f)(r)(ar); // but this is different from r.normalSource!(real)()(i)(r)(ar); r.normalD(2.0L)(i)(r)(ar); // as the source generates numbers of its type that then are simply cast to // the type needed. // Uniform distribution (as its creation for different types has no overhead) // is never cast, so that (for example) bounds exclusion for floats is really // guaranteed. // For the other distribution using a distribution of different type than // the variable should be done with care, as underflow/overflow might ensue. // // Some utility functions are also available int i2=r.uniform!(int)(); int i2=r.randomize(i); // both i and i2 are initialized to the same value float f2=r.normalSigma(3.0f);
) flexibility:
Quality:
the basic source can be easily be changed with something else Efficiency:
Annoyances: