Class: Normcore::Normal

Inherits:
Base
  • Object
show all
Defined in:
lib/normal.rb

Overview

The normal a.k.a. Gaussian distribution

en.wikipedia.org/wiki/Box–μller_transform

Usage:

normal = Normal.new(0, 1)

normal.rng # return one sample

normal.sample(10) # return 10 samples

Direct Known Subclasses

LogNormal

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#sample

Constructor Details

#initialize(μ, σ) ⇒ Normal

Returns a new instance of Normal.



18
19
20
21
# File 'lib/normal.rb', line 18

def initialize 

Instance Attribute Details

#μObject (readonly)

Returns the value of attribute μ.



16
17
18
# File 'lib/normal.rb', line 16

def 

#σObject (readonly)

Returns the value of attribute σ.



16
17
18
# File 'lib/normal.rb', line 16

def 

Instance Method Details

#rngObject

yield samples from gaussian distribution using the Box-μller transform



26
27
28
# File 'lib/normal.rb', line 26

def rng
  box_muller
end