View source code
Display the source code in std/random.d from which this page was generated on
github.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Page wiki
View or edit the community-maintained wiki page associated with this page.
Function std.random.uniform01
Generates a uniformly-distributed floating point number of type
T
in the range [0, 1). If no random number generator is
specified, the default RNG
will be used as the source
of randomness.
rndGen
offers a faster generation of random variates than
the equivalent uniform01
and so may be preferred
for some applications.
uniform
!"[)"(0.0, 1.0)
Prototypes
T uniform01(T)() if (isFloatingPoint!T); T uniform01(T, UniformRNG)( UniformRNG rng ) if (isFloatingPoint!T && isUniformRNG!UniformRNG);
Parameters
Name | Description |
---|---|
rng | (optional) random number generator to use;
if not specified, defaults to
|
Returns
Floating-point random variate of type T
drawn from the uniform
distribution across the half-open interval [0, 1).
Authors
Andrei Alexandrescu
Masahiro Nakagawa (Xorshift
random generator)
Joseph Rushton Wakeling (Algorithm D for random sampling)