Sha256: da96e9cbe31ae3836d0221eb64a443d5defddadbd058c0e7118478760795eaf8

Contents?: true

Size: 294 Bytes

Versions: 1

Compression:

Stored size: 294 Bytes

Contents

module Enumerable
  def sum
    inject(0){|sum, i| sum + i }
  end

  def mean
    sum / length.to_f
  end

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

  def standard_deviation
    Math.sqrt(sample_variance)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
standard-deviation-0.1.0 lib/enumerable/standard_deviation/standard_deviation.rb