Class: Pest::Function::Entropy::Builder

Inherits:
Object
  • Object
show all
Includes:
Builder
Defined in:
lib/pest/function/entropy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(estimator, variables) ⇒ Builder

Returns a new instance of Builder.



13
14
15
16
17
# File 'lib/pest/function/entropy.rb', line 13

def initialize(estimator, variables)
  @estimator      = estimator
  @event          = parse(variables)
  @givens         = [].to_set
end

Instance Attribute Details

#estimatorObject (readonly)

Returns the value of attribute estimator.



11
12
13
# File 'lib/pest/function/entropy.rb', line 11

def estimator
  @estimator
end

#eventObject (readonly)

Returns the value of attribute event.



11
12
13
# File 'lib/pest/function/entropy.rb', line 11

def event
  @event
end

#givensObject (readonly)

Returns the value of attribute givens.



11
12
13
# File 'lib/pest/function/entropy.rb', line 11

def givens
  @givens
end

Instance Method Details

#evaluateObject



24
25
26
27
28
29
30
31
32
# File 'lib/pest/function/entropy.rb', line 24

def evaluate
  joint = estimator.distributions[event].entropy
  if givens.empty?
    joint
  else
    conditional = estimator.distributions[givens].entropy
    joint - conditional
  end
end

#given(*variables) ⇒ Object



19
20
21
22
# File 'lib/pest/function/entropy.rb', line 19

def given(*variables)
  @givens.merge parse(variables)
  self
end