Class: RandomVariable::Generic
- Inherits:
-
Object
- Object
- RandomVariable::Generic
- Includes:
- Sampleable
- Defined in:
- lib/random_variable.rb
Direct Known Subclasses
Bernoulli, Beta, Binomial, ChiSquared, ContinuousUniform, DiscreteUniform, Exponential, F, Normal, Pareto, Poisson, Rademacher, Rayleigh, Rectangular
Instance Method Summary collapse
-
#initialize(&blk) ⇒ Generic
constructor
A new instance of Generic.
Methods included from Sampleable
Constructor Details
#initialize(&blk) ⇒ Generic
Returns a new instance of Generic.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/random_variable.rb', line 79 def initialize(&blk) @blk = blk class << self def outcome @blk.call end alias :sample :outcome def outcomes(nr_samples) ary = [] nr_samples.times do ary << @blk.call end class << ary include RandomVariable::Samples end ary end alias :samples :outcomes end end |