Class: RandomDistribution::ExponentialSequence
- Defined in:
- lib/redshift/util/random.rb
Constant Summary
Constants included from Math
Instance Attribute Summary collapse
-
#mean ⇒ Object
readonly
Returns the value of attribute mean.
Attributes inherited from Sequence
Instance Method Summary collapse
-
#initialize(opt = {}) ⇒ ExponentialSequence
constructor
A new instance of ExponentialSequence.
- #next ⇒ Object
Methods inherited from Sequence
random_pool_seed, random_seed, serial_count
Constructor Details
#initialize(opt = {}) ⇒ ExponentialSequence
Returns a new instance of ExponentialSequence.
109 110 111 112 |
# File 'lib/redshift/util/random.rb', line 109 def initialize opt = {} super @mean = Float(opt[:mean] || 1) end |
Instance Attribute Details
#mean ⇒ Object (readonly)
Returns the value of attribute mean.
107 108 109 |
# File 'lib/redshift/util/random.rb', line 107 def mean @mean end |
Instance Method Details
#next ⇒ Object
114 115 116 117 |
# File 'lib/redshift/util/random.rb', line 114 def next while (x=super) == 0.0; end return -log(x) * @mean end |