Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 4 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 4 additions and 14 deletions.
  1. +3 −13 lib/easystats.rb
  2. +1 −1 lib/easystats/version.rb
View
16 lib/easystats.rb
@@ -98,7 +98,7 @@ def range
return unless self.any?
data = self.sort
- data[data.count - 1] - data[0]
+ data.last - data.first
end unless Array.instance_methods.include? "range"
# take in an array of numbers and calculate the standard deviation
@@ -111,23 +111,13 @@ def standard_deviation
# take in an array of numbers and calculate the sum
def sum
- return unless self.any?
-
- sum_of_numbers = 0
-
- self.each do |num|
- sum_of_numbers += num
- end
-
- sum_of_numbers
+ self.reduce { |total, number| total + number }
end unless Array.instance_methods.include? "sum"
def variance
return unless self.any?
- sum_of_deviations = self.sum_of_deviations_squared
-
- sum_of_deviations / self.count.to_f
+ self.sum_of_deviations_squared / self.count.to_f
end unless Array.instance_methods.include? "variance"
protected
View
2 lib/easystats/version.rb
@@ -1,3 +1,3 @@
module Easystats
- VERSION = "0.2.0"
+ VERSION = "0.3.0"
end

No commit comments for this range

Something went wrong with that request. Please try again.