Class: ERV::SequentialRandomVariable

Inherits:
Object
  • Object
show all
Defined in:
lib/erv/random_variable.rb

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ SequentialRandomVariable

Returns a new instance of SequentialRandomVariable.

Raises:

  • (ArgumentError)


43
44
45
46
47
48
# File 'lib/erv/random_variable.rb', line 43

def initialize(args={})
  first = args.delete(:first_value)
  raise ArgumentError, "First value must be provided!" if first.nil?
  @most_recent = first.to_f
  @var = RandomVariable.new(args)
end

Instance Method Details

#nextObject Also known as: sample



50
51
52
# File 'lib/erv/random_variable.rb', line 50

def next
  @most_recent += @var.next
end