Range of random numbers
Joseph Rushton Wakeling
joseph.wakeling at webdrake.net
Tue Apr 24 18:12:46 PDT 2012
On 24/04/12 13:50, Christophe wrote:
> We could also use a template to make a range out of a delegate and avoid
> this workarround...
What I'd _really_ like to see is something which would allow you to generate a
range of random numbers with an expression like,
auto rr = randomRange!distribution(/* distribution parameters */);
or,
auto rr = randomRange!distribution(size_t n, /* distribution parameters */);
... which would generate you either an infinite or length-n range of random
numbers generated by the specified distribution, with the passed parameters.
So, you could call e.g.,
auto rr = randomRange!(uniform!"()")(100, 0.0, 1.0);
auto rr = randomRange!pareto(100, alpha, sigma);
auto rr = randomRange!exponential(lambda);
... etc. But I'm not sure if this is feasible.
More information about the Digitalmars-d-learn
mailing list