Sha256: 9e34e3510c42e26eedcd4d52dc1db7e8e167e7ff7cd1c1b70ddc9775a54624c4

Contents?: true

Size: 627 Bytes

Versions: 1

Compression:

Stored size: 627 Bytes

Contents

class Easystats
  def self

  end

  # take in an array of numbers and calculate the mean (average)
  def mean(data)
    sum_of_numbers = 0

    data.each do |num|
      sum_of_numbers += num
    end

    sum_of_numbers / data.count
  end

  # take in an array of numbers and calculate the standard deviation
  def standard_deviation(data)
    average = self.mean(data)
    deviations = Array.new
    sum_of_deviations = 0

    data.each do |num|
      deviations.push((num-average)**2)
    end

    deviations.each do |num|
      sum_of_deviations += num
    end

    Math::sqrt(sum_of_deviations / (data.count-1))
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
easystats-0.0.1 lib/easystats.rb