Sha256: d23b37f17ee99d2d225b471fdbb3cd667b671513d8e9f654690ace6f221f719e

Contents?: true

Size: 489 Bytes

Versions: 1

Compression:

Stored size: 489 Bytes

Contents

# Name::      Sysadmin::ArrayExtension
# Author::    774 <http://id774.net>
# Created::   Aug 20, 2013
# Updated::   Aug 20, 2013
# Copyright:: 774 Copyright (c) 2013
# License::   Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.

class Array

  def average
    inject(0.0) { |sum, i| sum += i } / size
  end

  def variance
    ave = self.average
    inject(0.0) { |sum, i| sum += (i - ave)**2 } / size
  end

  def standard_devitation
    Math::sqrt(self.variance)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sysadmin-0.1.4 lib/sysadmin/array_ext.rb