class Rand
- Rand
- Reference
- Object
Defined in:
randn.crConstructors
-
.new(seed : UInt64, sequence = 0_u64)
Initializes an instance with the given seed and sequence.
-
.new(random : Random)
Initializes an instance with the given random object.
-
.new
Initializes an instance with a random seed.
Macro Summary
Instance Method Summary
-
#randn(mean, std_dev) : Float64
Generates a random number from a normal distribution.
-
#randn : Float64
Generates a random number from a standard normal distribution.
- #random : Random
Constructor Detail
def self.new(seed : UInt64, sequence = 0_u64)
#
Initializes an instance with the given seed and sequence.
Macro Detail
Instance Method Detail
def randn(mean, std_dev) : Float64
#
Generates a random number from a normal distribution.
This method generates a random number from a normal distribution with a given mean and standard deviation std_dev.
r = Rand.new
r.randn(0, 1) # => 0.1.9288478880269821
def randn : Float64
#
Generates a random number from a standard normal distribution.
This method uses the Box-Muller transform to generate a random number from a standard normal distribution. The generated number will have a mean of 0 and a standard deviation of 1.
r = Rand.new
r.randn # => 0.1.9288478880269821