Class: Wilson::Interval
- Inherits:
-
Object
- Object
- Wilson::Interval
- Defined in:
- lib/wilson_interval.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ Interval
constructor
A new instance of Interval.
- #lower_bound ⇒ Object
- #upper_bound ⇒ Object
Constructor Details
#initialize(options) ⇒ Interval
Returns a new instance of Interval.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/wilson_interval.rb', line 5 def initialize() @o = @o[:confidence] ||= 0.95 raise "Need to specify :n" unless @o[:total] unless @o[:p_hat] raise "Need to specify :p_hat or :successes" unless @o[:successes] @o[:p_hat] = @o[:successes].to_f / @o[:total] unless @o[:total] == 0 end end |
Instance Method Details
#lower_bound ⇒ Object
16 17 18 19 |
# File 'lib/wilson_interval.rb', line 16 def lower_bound return nil if @o[:total] == 0 (center - plus_minus) / denominator end |
#upper_bound ⇒ Object
21 22 23 24 |
# File 'lib/wilson_interval.rb', line 21 def upper_bound return nil if @o[:total] == 0 (center + plus_minus) / denominator end |