Class: Starter::Random::ExponentialSequence

Inherits:
Sequence
  • Object
show all
Defined in:
lib/starter/random.rb

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.



117
118
119
120
# File 'lib/starter/random.rb', line 117

def initialize opt = {}
  super
  @mean = Float(opt[:mean] || 1)
end

Instance Attribute Details

#meanObject (readonly)

Returns the value of attribute mean.



115
116
117
# File 'lib/starter/random.rb', line 115

def mean
  @mean
end

Instance Method Details

#nextObject



122
123
124
125
# File 'lib/starter/random.rb', line 122

def next
  while (x=super) == 0.0; end
  return -log(x) * @mean
end