Sha256: b39d93ae23d4fcca0f94f389ef6608d9cde1fc8979a6b44b37e97391dc4958a1

Contents?: true

Size: 325 Bytes

Versions: 1

Compression:

Stored size: 325 Bytes

Contents

class Array
  def central_moment k
    if k < 0
      nil
    else
      mean = self.mean

      (1.0 / self.length) * self.map{ |x| (x - mean) ** k }.sum
    end
  end

  def raw_moment k
    if k < 0
      nil
    else
      (1.0 / self.length) * self.map{ |x| x ** k }.sum
    end
  end

  # def l_moment k
  #
  # end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rstat-0.1.0 lib/rstat/core_ext/array/descriptive_statistics/shape/moment.rb