Mir Random [WIP]
Joseph Rushton Wakeling via Digitalmars-d
digitalmars-d at puremagic.com
Tue Nov 22 16:36:24 PST 2016
On Tuesday, 22 November 2016 at 06:31:45 UTC, Ilya Yaroshenko
wrote:
> ##### Integer uniform generators
> [WIP]
>
> ##### Real uniform generators
> [WIP]
>
> ##### Nonuniform generators
> [WIP]
As we discussed in relation to Seb's project, I think this is a
problematic conceptualization of the best way to structure
functionality related to randomness.
An arguably better way (as outlined in the C++11 standard) is to
think in terms of:
* random _generators_, i.e. sources of uniformly distributed
random bits:
- random _engines_ (seedable, pseudo-random algorithms)
- random _devices_ (non-deterministic sources of uniformly
distributed bits)
* random _distributions_, which transform uniformly-distributed
random bits
into variates with some other type and distribution
- note _this includes uniformly-distributed integers_!
- also uniformly-distributed floats, enums, etc.
- and also non-uniform distributions
* random _algorithms_, i.e. algorithms in the sense of
std.random, but where
their popFront() includes random decision-making
- randomCover, randomSample, etc.
The point of the above breakdown is that it gives a nice and
clear separation of concerns that allows for easily replaceable
components. Separating out stuff just by the ultimate result you
want (integers vs. floats, uniform vs. non-uniform, etc.) isn't
helpful in that way.
More information about the Digitalmars-d
mailing list