Module: Math::Array

Defined in:
lib/profiler.rb

Instance Method Summary collapse

Instance Method Details

#meanObject



8
9
10
# File 'lib/profiler.rb', line 8

def mean
  self.sum/self.length.to_f
end

#sample_varianceObject



12
13
14
15
16
# File 'lib/profiler.rb', line 12

def sample_variance
  m = self.mean
  sum = self.inject(0) { |accum, i| accum + (i - m) ** 2 }
  sum / (self.length).to_f
end

#standard_deviationObject



18
19
20
# File 'lib/profiler.rb', line 18

def standard_deviation
  return Math.sqrt(self.sample_variance)
end

#sumObject



4
5
6
# File 'lib/profiler.rb', line 4

def sum
  self.inject(0){ |accum, i| accum + i }
end