Class: Benchmark::IPS::Stats::Bootstrap
- Inherits:
-
Object
- Object
- Benchmark::IPS::Stats::Bootstrap
- Defined in:
- lib/project/ips/stats/bootstrap.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #central_tendency ⇒ Object
- #dependencies ⇒ Object
- #error ⇒ Object
- #footer ⇒ Object
-
#initialize(samples, confidence) ⇒ Bootstrap
constructor
A new instance of Bootstrap.
- #slowdown(baseline) ⇒ Object
Constructor Details
#initialize(samples, confidence) ⇒ Bootstrap
Returns a new instance of Bootstrap.
9 10 11 12 13 14 15 16 17 |
# File 'lib/project/ips/stats/bootstrap.rb', line 9 def initialize(samples, confidence) dependencies @iterations = 10_000 @confidence = (confidence / 100.0).to_s @data = Kalibera::Data.new({[0] => samples}, [1, samples.size]) interval = @data.bootstrap_confidence_interval(@iterations, @confidence) @median = interval.median @error = interval.error end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
7 8 9 |
# File 'lib/project/ips/stats/bootstrap.rb', line 7 def data @data end |
Instance Method Details
#central_tendency ⇒ Object
19 20 21 |
# File 'lib/project/ips/stats/bootstrap.rb', line 19 def central_tendency @median end |
#dependencies ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/project/ips/stats/bootstrap.rb', line 37 def dependencies require 'kalibera' rescue LoadError puts puts "Can't load the kalibera gem - this is required to use the :bootstrap stats options." puts "It's optional, so we don't formally depend on it and it isn't installed along with benchmark-ips." puts "You probably want to do something like 'gem install kalibera' to fix this." abort end |
#error ⇒ Object
23 24 25 |
# File 'lib/project/ips/stats/bootstrap.rb', line 23 def error @error end |
#footer ⇒ Object
33 34 35 |
# File 'lib/project/ips/stats/bootstrap.rb', line 33 def "with #{(@confidence.to_f * 100).round(1)}% confidence" end |