Normal distribution
Joseph Rushton Wakeling via Digitalmars-d
digitalmars-d at puremagic.com
Fri Feb 26 12:48:08 PST 2016
On Friday, 26 February 2016 at 20:15:10 UTC, Andrei Alexandrescu
wrote:
> Would it work to define Gaussian generators as regular
> generators (same as the existing ones), which keep the uniform
> engine as a member?
Assuming that the uniform engine was uniquely and only used by
that Gaussian generator, yes, that would be OK (although I think
we can do better). If you try and take that approach using the
same uniform generator as you're using in other parts of the
code, it'll likely be problematic, unless the Gaussian stores a
reference to that RNG rather than a by-value copy.
Another approach, maybe more flexible given the current state of
things, would be to define a functor whose opCall takes a uniform
RNG as a parameter by ref, and which returns floating-point
values distributed according to the Gaussian distribution.
I still think, though, that we need to solve the fundamental
architectural problems of how to implement random algorithms in
range form, before we can really get a nice solution.
I'm going to try and prepare some notes on that soon -- bug me if
I don't come up with the goods.
More information about the Digitalmars-d
mailing list