Class: ABBA::Bayes::BinaryOutcomeTest
- Inherits:
-
Object
- Object
- ABBA::Bayes::BinaryOutcomeTest
- Defined in:
- lib/abba/bayes.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(variant_a, variant_b) ⇒ BinaryOutcomeTest
constructor
A new instance of BinaryOutcomeTest.
Constructor Details
#initialize(variant_a, variant_b) ⇒ BinaryOutcomeTest
Returns a new instance of BinaryOutcomeTest.
4 5 6 7 |
# File 'lib/abba/bayes.rb', line 4 def initialize(variant_a, variant_b) @variant_a = variant_a @variant_b = variant_b end |
Instance Method Details
#call ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/abba/bayes.rb', line 9 def call total = 0.0 (0..(alpha_a-1)).each do |i| log_contribution = Math.lbeta(alpha_b+i, beta_a+beta_b) - Math.log(beta_a+i) - Math.lbeta(1+i, beta_a) - Math.lbeta(alpha_b, beta_b) total += Math.exp(log_contribution) end total end |