class Rand

Defined in:

randn.cr

Constructors

Macro Summary

Instance Method Summary

Constructor Detail

def self.new(seed : UInt64, sequence = 0_u64) #

Initializes an instance with the given seed and sequence.


[View source]
def self.new(random : Random) #

Initializes an instance with the given random object.


[View source]
def self.new #

Initializes an instance with a random seed.


[View source]

Macro Detail

macro method_missing(call) #

[View source]

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

[View source]
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

[View source]
def random : Random #

[View source]