Module: Kernel

Defined in:
lib/edhd.rb

Instance Method Summary collapse

Instance Method Details

#experiment(name = "default", seed = rand) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/edhd.rb', line 5

def experiment(name = "default", seed = rand)
  $hypothesis_sets ||= []
  $hypothesis_sets << []
  yield
  hypothesis_set = $hypothesis_sets.pop
  hypothesis_name, block = hypothesis_set[seed.to_s.hash % hypothesis_set.length]
  block.call
  $observer.hypothesized(name, hypothesis_name, seed)
end

#hypothesis(name, weight = 1, &block) ⇒ Object



15
16
17
18
19
# File 'lib/edhd.rb', line 15

def hypothesis(name, weight = 1, &block)
  weight.times do
    $hypothesis_sets.last << [name, block]
  end
end

#observation(name, value, seed) ⇒ Object



21
22
23
# File 'lib/edhd.rb', line 21

def observation(name, value, seed)
  $observer.observed(name, value, seed)
end