Sha256: ffe304a49da16b5d6e52cf98724f20aabf9fe199fddc1e01023c372b4e02dba3

Contents?: true

Size: 320 Bytes

Versions: 41

Compression:

Stored size: 320 Bytes

Contents

require 'active_support/core_ext/enumerable'

module Enumerable
  def mean
    sum.to_f / length
  end

  def variance
    m = mean
    reduce(0) {|accum, item| accum + (item - m) ** 2}.to_f / (length - 1)
  end

  def stdev
    Math.sqrt(variance)
  end

  def percentile(pc)
    sort[(pc * length).ceil - 1]
  end
end

Version data entries

41 entries across 41 versions & 2 rubygems

Version Path
liquid-ext-3.5.3 lib/liquid/ext/enumerable.rb
liquid-ext-3.5.2 lib/liquid/ext/enumerable.rb
liquid-ext-3.5.0 lib/liquid/ext/enumerable.rb
liquid-ext-3.4.2 lib/liquid/ext/enumerable.rb
liquid-ext-3.4.1 lib/liquid/ext/enumerable.rb
liquid-ext-3.4.0 lib/liquid/ext/enumerable.rb
liquid-ext-3.3.10 lib/liquid/ext/enumerable.rb
liquid-ext-3.3.9 lib/liquid/ext/enumerable.rb
liquid-ext-3.3.8 lib/liquid/ext/enumerable.rb
liquid-ext-3.3.7 lib/liquid/ext/enumerable.rb
liquid-ext-3.3.6 lib/liquid/ext/enumerable.rb
liquid-ext-3.3.5 lib/liquid/ext/enumerable.rb
liquid-ext-3.3.4 lib/liquid/ext/enumerable.rb
liquid-ext-3.3.3 lib/liquid/ext/enumerable.rb
liquid-ext-3.3.2 lib/liquid/ext/enumerable.rb
liquid-ext-3.3.0 lib/liquid/ext/enumerable.rb
liquid-ext-3.2.0 lib/liquid/ext/enumerable.rb
liquid-ext-3.1.2 lib/liquid/ext/enumerable.rb
liquid-ext-3.1.1 lib/liquid/ext/enumerable.rb
liquid-ext-3.1.0 lib/liquid/ext/enumerable.rb