Class: Pest::Function::Entropy::Builder
- Inherits:
-
Object
- Object
- Pest::Function::Entropy::Builder
- Includes:
- Builder
- Defined in:
- lib/pest/function/entropy.rb
Instance Attribute Summary collapse
-
#estimator ⇒ Object
readonly
Returns the value of attribute estimator.
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#givens ⇒ Object
readonly
Returns the value of attribute givens.
Instance Method Summary collapse
- #evaluate ⇒ Object
- #given(*variables) ⇒ Object
-
#initialize(estimator, variables) ⇒ Builder
constructor
A new instance of Builder.
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
#estimator ⇒ Object (readonly)
Returns the value of attribute estimator.
11 12 13 |
# File 'lib/pest/function/entropy.rb', line 11 def estimator @estimator end |
#event ⇒ Object (readonly)
Returns the value of attribute event.
11 12 13 |
# File 'lib/pest/function/entropy.rb', line 11 def event @event end |
#givens ⇒ Object (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
#evaluate ⇒ Object
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 |