Class: RandomDistribution::ExponentialSequence

Inherits:
Sequence show all
Defined in:
lib/redshift/util/random.rb

Constant Summary

Constants included from Math

Math::Infinity

Instance Attribute Summary collapse

Attributes inherited from Sequence

#generator

Instance Method Summary collapse

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

#meanObject (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

#nextObject



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