Class: Stats::TimingStat
- Inherits:
-
Array
- Object
- Array
- Stats::TimingStat
- Defined in:
- lib/stats/timing_stat.rb
Instance Method Summary collapse
-
#average ⇒ Object
Returns the average value.
-
#population_variance ⇒ Object
Returns the sample variance of the values.
-
#standard_deviation ⇒ Object
Returns the standard deviation of the values.
Instance Method Details
#average ⇒ Object
Returns the average value.
4 5 6 |
# File 'lib/stats/timing_stat.rb', line 4 def average sum / length.to_f end |
#population_variance ⇒ Object
Returns the sample variance of the values.
9 10 11 12 |
# File 'lib/stats/timing_stat.rb', line 9 def population_variance avg = average 1 / length.to_f * inject(0) { |acc, i| acc + (i - avg) ** 2 } end |
#standard_deviation ⇒ Object
Returns the standard deviation of the values.
15 16 17 |
# File 'lib/stats/timing_stat.rb', line 15 def standard_deviation Math.sqrt(population_variance) end |