On Friday, 26 February 2016 at 20:15:10 UTC, Andrei Alexandrescu wrote:
On 2/26/16 2:32 PM, Joseph Rushton Wakeling wrote:
Yup. The basic problem of getting this stuff into phobos are the
architectural problems discussed in that talk.  Unlike uniform
distribution (which is straightforward to implement as a function, no questions asked), the normal distribution is best implemented as a range which keeps some state. So the reference-type/non-reference-type issues
start becoming a factor.

Would it work to define Gaussian generators as regular generators (same as the existing ones), which keep the uniform engine as a member? -- Andrei

This C implementation of the Marsaglia/Tsang Ziggurat method keeps no state except for that of the uniform rng and 3 small static lookup tables that can be initialized in the module's shared constructor:
http://people.sc.fsu.edu/~jburkardt/cpp_src/ziggurat_inline/ziggurat_inline.cpp

I wrote a D implementation of that with the uniform rngs factored out, leaving it at ~50 loc - not up to Phobos' standards for sure - but I suppose but it could be a starting point. If someone is interested in that let me know.

Reply via email to