Class: Pest::Function::Probability::Builder
- Inherits:
-
Object
- Object
- Pest::Function::Probability::Builder
- Includes:
- Builder
- Defined in:
- lib/pest/function/probability.rb
Instance Attribute Summary collapse
-
#estimator ⇒ Object
Returns the value of attribute estimator.
-
#event ⇒ Object
Returns the value of attribute event.
-
#givens ⇒ Object
Returns the value of attribute givens.
Instance Method Summary collapse
- #evaluate ⇒ Object
- #given(given) ⇒ Object
-
#initialize(estimator, event) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(estimator, event) ⇒ Builder
Returns a new instance of Builder.
53 54 55 56 57 |
# File 'lib/pest/function/probability.rb', line 53 def initialize(estimator, event) @estimator = estimator @event = event @givens = Hash.new end |
Instance Attribute Details
#estimator ⇒ Object
Returns the value of attribute estimator.
51 52 53 |
# File 'lib/pest/function/probability.rb', line 51 def estimator @estimator end |
#event ⇒ Object
Returns the value of attribute event.
51 52 53 |
# File 'lib/pest/function/probability.rb', line 51 def event @event end |
#givens ⇒ Object
Returns the value of attribute givens.
51 52 53 |
# File 'lib/pest/function/probability.rb', line 51 def givens @givens end |
Instance Method Details
#evaluate ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/pest/function/probability.rb', line 65 def evaluate data_hash = event.merge(givens) data_hash.each_key {|key| data_hash[key] = Array(data_hash[key])} data = Pest::DataSet::Hash.from_hash(data_hash) BatchBuilder.new(estimator, event.keys). given(*givens.keys).in(data). evaluate.first end |
#given(given) ⇒ Object
59 60 61 62 63 |
# File 'lib/pest/function/probability.rb', line 59 def given(given) givens.merge! given raise ArgumentError unless (given.keys.to_set - @estimator.variables).empty? self end |