Class: RandomVariable::Generic

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

Instance Method Summary collapse

Constructor Details

#initialize(&blk) ⇒ Generic

Returns a new instance of Generic.



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

def initialize(&blk)
	@blk = blk
end

Instance Method Details

#outcomeObject Also known as: sample

obtain a single outcome from the random variable



72
73
74
# File 'lib/random_variable.rb', line 72

def outcome
	@blk.call
end

#outcomes(number) ⇒ Object Also known as: samples

obtain number outcomes from the random variable



78
79
80
81
82
83
84
# File 'lib/random_variable.rb', line 78

def outcomes(number)
	ary = []
	number.times do
		ary << @blk.call
	end
	ary	
end