Class: WBench::Stats

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/wbench/stats.rb

Instance Method Summary collapse

Instance Method Details

#meanObject



11
12
13
# File 'lib/wbench/stats.rb', line 11

def mean
  sum / length.to_f
end

#medianObject



3
4
5
# File 'lib/wbench/stats.rb', line 3

def median
  sort[length / 2]
end

#sample_varianceObject



15
16
17
# File 'lib/wbench/stats.rb', line 15

def sample_variance
  (inject(0) { |variance, value| variance + ((value - mean) ** 2) }) / length
end

#std_devObject



19
20
21
# File 'lib/wbench/stats.rb', line 19

def std_dev
  Math.sqrt(sample_variance)
end

#sumObject



7
8
9
# File 'lib/wbench/stats.rb', line 7

def sum
  inject(:+)
end