Ravn::

EnumerableRefinements module

Aggregate functions for Enumerables; adapted from:

Public Instance Methods

mean()

Calculate the mean of the members of the collection.

# File lib/ravn/mixins.rb, line 688
def mean
        return self.sum / self.length.to_f
end
sample_variance()

Calculate the sample variance of the members of the collection.

# File lib/ravn/mixins.rb, line 694
def sample_variance
        m = self.mean
        sum = self.inject( 0 ) {|accum, i| accum + (i-m) ** 2 }
        return sum / (self.length - 1).to_f
end
standard_deviation()

Calculate the deviation from the mean of the members of the collection.

# File lib/ravn/mixins.rb, line 702
def standard_deviation
        return Math.sqrt( self.sample_variance )
end