Class: Distrb::Normal
- Inherits:
-
Distribution
- Object
- Distribution
- Distrb::Normal
- Defined in:
- lib/distrb/normal.rb
Overview
Normal distribution See: en.wikipedia.org/wiki/Normal_distribution
Defined Under Namespace
Classes: BoxMullerTransform
Instance Attribute Summary collapse
-
#mean ⇒ Object
readonly
Returns the value of attribute mean.
-
#sampler ⇒ Object
readonly
Returns the value of attribute sampler.
-
#stdev ⇒ Object
readonly
Returns the value of attribute stdev.
Instance Method Summary collapse
-
#initialize(mean = 0.0, stdev = 1.0) ⇒ Normal
constructor
A new instance of Normal.
- #sample ⇒ Object
Constructor Details
#initialize(mean = 0.0, stdev = 1.0) ⇒ Normal
Returns a new instance of Normal.
12 13 14 15 16 |
# File 'lib/distrb/normal.rb', line 12 def initialize mean = 0.0, stdev = 1.0 @sampler = BoxMullerTransform.new @mean = mean @stdev = stdev end |
Instance Attribute Details
#mean ⇒ Object (readonly)
Returns the value of attribute mean.
10 11 12 |
# File 'lib/distrb/normal.rb', line 10 def mean @mean end |
#sampler ⇒ Object (readonly)
Returns the value of attribute sampler.
10 11 12 |
# File 'lib/distrb/normal.rb', line 10 def sampler @sampler end |
#stdev ⇒ Object (readonly)
Returns the value of attribute stdev.
10 11 12 |
# File 'lib/distrb/normal.rb', line 10 def stdev @stdev end |
Instance Method Details
#sample ⇒ Object
18 19 20 |
# File 'lib/distrb/normal.rb', line 18 def sample super * self.stdev + self.mean end |