class MonteCarlo::ExperimentDSL
Class to setup an experiment using a DSL syntax
Public Class Methods
new(experiment)
click to toggle source
Initializes a DSL instance for the given experiment
@example
experiment = MonteCarlo::Experiment.new do times 100000 sample_method { rand(10) } computation { |sample| sample >= 5 } end
@param experiment [MonteCarlo::Experiment] the experiment to configure @return [MonteCarlo::ExperimentDSL]
# File lib/monte_carlo/experiment_dsl.rb, line 16 def initialize(experiment) @experiment = experiment end
Public Instance Methods
computation(&block)
click to toggle source
Set the computation method of the experiment
@param block [Block]
# File lib/monte_carlo/experiment_dsl.rb, line 37 def computation(&block) @experiment.computation = block end
reset(&block)
click to toggle source
Set the reset method of the experiment
@param block [Block]
# File lib/monte_carlo/experiment_dsl.rb, line 51 def reset(&block) @experiment.reset = block end
sample_method(&block)
click to toggle source
Set the sample method of the experiment
@param block [Block]
# File lib/monte_carlo/experiment_dsl.rb, line 30 def sample_method(&block) @experiment.sample_method = block end
setup(&block)
click to toggle source
Set the setup method of the experiment
@param block [Block]
# File lib/monte_carlo/experiment_dsl.rb, line 44 def setup(&block) @experiment.setup = block end
times(times)
click to toggle source
Set the number of samples to generate
@param times [#times]
# File lib/monte_carlo/experiment_dsl.rb, line 23 def times(times) @experiment.times = times end