Class: ERV::SequentialRandomVariable
- Defined in:
- lib/erv/random_variable.rb
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ SequentialRandomVariable
constructor
A new instance of SequentialRandomVariable.
- #next ⇒ Object (also: #sample)
Constructor Details
#initialize(opts = {}) ⇒ SequentialRandomVariable
Returns a new instance of SequentialRandomVariable.
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
#next ⇒ Object Also known as: sample
51 52 53 |
# File 'lib/erv/random_variable.rb', line 51 def next @most_recent += @var.next end |