digitalmars.D - Normal distribution
- Andrei Alexandrescu (2/2) Feb 20 2016 Do we have a good quality converter of uniform numbers to
- Edwin van Leeuwen (4/6) Feb 20 2016 There is one in dstats:
- Andrei Alexandrescu (3/8) Feb 26 2016 Thanks! I ended up using this. Is someone working on adding Gaussians to...
- John Colvin (5/15) Feb 26 2016 https://github.com/WebDrake/hap is intended as a replacement for
- Joseph Rushton Wakeling (9/25) Feb 26 2016 Yup. The basic problem of getting this stuff into phobos are the
- Andrei Alexandrescu (3/9) Feb 26 2016 Would it work to define Gaussian generators as regular generators (same
- Joseph Rushton Wakeling (17/20) Feb 26 2016 Assuming that the uniform engine was uniquely and only used by
- =?UTF-8?B?TcOhcmNpbw==?= Martins (11/25) Feb 28 2016 This C implementation of the Marsaglia/Tsang Ziggurat method
- Leandro Motta Barros via Digitalmars-d (11/13) Feb 20 2016 Maybe not good quality, but I like this one for my ludic purposes:
- Guillaume Piolat (4/6) Feb 20 2016 Not sure if good quality but:
- John Colvin (10/12) Feb 20 2016 There is this, from years ago:
- Timon Gehr (3/5) Feb 20 2016 I don't know about quality, but the following is in Phobos:
- asdf (5/7) Feb 28 2016 Forth Engineering Practice™ is to add a few uniform distributions
Do we have a good quality converter of uniform numbers to Gaussian-distributed numbers around? -- Andrei
Feb 20 2016
On Saturday, 20 February 2016 at 14:01:22 UTC, Andrei Alexandrescu wrote:Do we have a good quality converter of uniform numbers to Gaussian-distributed numbers around? -- AndreiThere is one in dstats: https://github.com/DlangScience/dstats/blob/master/source/dstats/random.d#L266
Feb 20 2016
On 02/20/2016 09:06 AM, Edwin van Leeuwen wrote:On Saturday, 20 February 2016 at 14:01:22 UTC, Andrei Alexandrescu wrote:Thanks! I ended up using this. Is someone working on adding Gaussians to phobos? -- AndreiDo we have a good quality converter of uniform numbers to Gaussian-distributed numbers around? -- AndreiThere is one in dstats: https://github.com/DlangScience/dstats/blob/master/source/dstats/random.d#L266
Feb 26 2016
On Friday, 26 February 2016 at 18:23:41 UTC, Andrei Alexandrescu wrote:On 02/20/2016 09:06 AM, Edwin van Leeuwen wrote:https://github.com/WebDrake/hap is intended as a replacement for std.random and includes distributions (see e.g. https://github.com/WebDrake/hap/blob/master/source/hap/random/d stribution.d#L441). Also, remember http://dconf.org/2015/talks/wakeling.htmlOn Saturday, 20 February 2016 at 14:01:22 UTC, Andrei Alexandrescu wrote:Thanks! I ended up using this. Is someone working on adding Gaussians to phobos? -- AndreiDo we have a good quality converter of uniform numbers to Gaussian-distributed numbers around? -- AndreiThere is one in dstats: https://github.com/DlangScience/dstats/blob/master/source/dstats/random.d#L266
Feb 26 2016
On Friday, 26 February 2016 at 19:11:15 UTC, John Colvin wrote:On Friday, 26 February 2016 at 18:23:41 UTC, Andrei Alexandrescu 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. That said, it's _possible_ to implement a simple normal-variate-generator as a function, it's just inefficient.On 02/20/2016 09:06 AM, Edwin van Leeuwen wrote:https://github.com/WebDrake/hap is intended as a replacement for std.random and includes distributions (see e.g. https://github.com/WebDrake/hap/blob/master/source/hap/random/d stribution.d#L441). Also, remember http://dconf.org/2015/talks/wakeling.htmlOn Saturday, 20 February 2016 at 14:01:22 UTC, Andrei Alexandrescu wrote:Thanks! I ended up using this. Is someone working on adding Gaussians to phobos? -- AndreiDo we have a good quality converter of uniform numbers to Gaussian-distributed numbers around? -- AndreiThere is one in dstats: https://github.com/DlangScience/dstats/blob/master/source/dstats/random.d#L266
Feb 26 2016
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
Feb 26 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.
Feb 26 2016
On Friday, 26 February 2016 at 20:15:10 UTC, Andrei Alexandrescu wrote:On 2/26/16 2:32 PM, Joseph Rushton Wakeling wrote: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.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
Feb 28 2016
Maybe not good quality, but I like this one for my ludic purposes: https://github.com/lmbarros/sbxs_dlang/blob/master/src/sbxs/rand/rng.d#L283 It is an implementation of an approximation algorithm that used to be described here: http://home.online.no/~pjacklam/notes/invnorm/ But appears to be offline right now. On the Wayback Machine: http://web.archive.org/web/20151030212409/http://home.online.no/~pjacklam/notes/invnorm <http://web.archive.org/web/20151030212409/http://home.online.no/~pjacklam/notes/invnorm> LMB On Sat, Feb 20, 2016 at 12:01 PM, Andrei Alexandrescu via Digitalmars-d < digitalmars-d puremagic.com> wrote:Do we have a good quality converter of uniform numbers to Gaussian-distributed numbers around? -- Andrei
Feb 20 2016
On Saturday, 20 February 2016 at 14:01:22 UTC, Andrei Alexandrescu wrote:Do we have a good quality converter of uniform numbers to Gaussian-distributed numbers around? -- AndreiNot sure if good quality but: https://d-gamedev-team.github.io/gfm/gfm.math.simplerng.html
Feb 20 2016
On Saturday, 20 February 2016 at 14:01:22 UTC, Andrei Alexandrescu wrote:Do we have a good quality converter of uniform numbers to Gaussian-distributed numbers around? -- AndreiThere is this, from years ago: https://github.com/DlangScience/dstats/blob/master/source/dstats/random.d#L266 and the range wrappers also in that module. There is also of course https://github.com/WebDrake/hap/blob/master/source/hap/random/distribution.d#L507 But as you will remember from many messages from Joseph Rushton Wakeling, he's been blocked by difficulties with the range API, which also apply to the dstats version.
Feb 20 2016
On 20.02.2016 15:01, Andrei Alexandrescu wrote:Do we have a good quality converter of uniform numbers to Gaussian-distributed numbers around? -- AndreiI don't know about quality, but the following is in Phobos: https://dlang.org/phobos/std_mathspecial.html#.normalDistributionInverse
Feb 20 2016
On Saturday, 20 February 2016 at 14:01:22 UTC, Andrei Alexandrescu wrote:Do we have a good quality converter of uniform numbers to Gaussian-distributed numbers around? -- AndreiForth Engineering Practice™ is to add a few uniform distributions together... http://www.colorforth.com/e-x2.htm Accurate to 2 decimal places!
Feb 28 2016