Class: Distrb::Normal

Inherits:
Distribution show all
Defined in:
lib/distrb/normal.rb

Overview

Defined Under Namespace

Classes: BoxMullerTransform

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#meanObject (readonly)

Returns the value of attribute mean.



10
11
12
# File 'lib/distrb/normal.rb', line 10

def mean
  @mean
end

#samplerObject (readonly)

Returns the value of attribute sampler.



10
11
12
# File 'lib/distrb/normal.rb', line 10

def sampler
  @sampler
end

#stdevObject (readonly)

Returns the value of attribute stdev.



10
11
12
# File 'lib/distrb/normal.rb', line 10

def stdev
  @stdev
end

Instance Method Details

#sampleObject



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

def sample
  super * self.stdev + self.mean
end