Class: ERV::SequentialRandomVariable

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

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ SequentialRandomVariable

Returns a new instance of SequentialRandomVariable.

Raises:

  • (ArgumentError)


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

def initialize(opts={})
  args = opts.dup
  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



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

def next
  @most_recent += @var.next
end