class NormalRandom
Constants
- DEFAULT_MU
- DEFAULT_SIGMA
- VERSION
Attributes
rng[RW]
Public Class Methods
new()
click to toggle source
# File lib/normal_random.rb, line 10 def initialize self.rng = Random.new end
Public Instance Methods
box_muller()
click to toggle source
# File lib/normal_random.rb, line 18 def box_muller Math.sqrt(-2*Math.log(rng.rand))*Math.cos(2*Math::PI*rng.rand) end
Also aliased as: standard_deviations
rand(mu: DEFAULT_MU, sigma: DEFAULT_SIGMA)
click to toggle source
# File lib/normal_random.rb, line 14 def rand(mu: DEFAULT_MU, sigma: DEFAULT_SIGMA) (standard_deviations * sigma) + mu end