Class: WBench::Stats
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- WBench::Stats
- Defined in:
- lib/wbench/stats.rb
Instance Method Summary collapse
Instance Method Details
#mean ⇒ Object
11 12 13 |
# File 'lib/wbench/stats.rb', line 11 def mean sum / length.to_f end |
#median ⇒ Object
3 4 5 |
# File 'lib/wbench/stats.rb', line 3 def median sort[length / 2] end |
#sample_variance ⇒ Object
15 16 17 |
# File 'lib/wbench/stats.rb', line 15 def sample_variance (inject(0) { |variance, value| variance + ((value - mean) ** 2) }) / length end |
#std_dev ⇒ Object
19 20 21 |
# File 'lib/wbench/stats.rb', line 19 def std_dev Math.sqrt(sample_variance) end |
#sum ⇒ Object
7 8 9 |
# File 'lib/wbench/stats.rb', line 7 def sum inject(:+) end |