Top Level Namespace

Defined Under Namespace

Modules: MachineHead

Instance Method Summary collapse

Instance Method Details

#avg(values) ⇒ Object



8
9
10
# File 'bin/scanner.rb', line 8

def avg(values)
  values.inject(:+) / values.size.to_f
end

#stddev(values) ⇒ Object



12
13
14
15
16
17
# File 'bin/scanner.rb', line 12

def stddev(values)
  count = values.size
  mean = avg(values)

  Math.sqrt(values.inject(0){|sum, e| sum + (e - mean) ** 2} / count.to_f)
end