Browse Source

Rename quadratic mean

pull/2/head
Arthur POULET 4 years ago
parent
commit
5120570423
No known key found for this signature in database GPG Key ID: FC154EA63FF5D8BC
  1. 2
      README.md
  2. 4
      spec/math/mean.cr
  3. 2
      src/lib/math/mean.cr

2
README.md

@ -68,7 +68,7 @@ Math.factorial(4) # => 24
[1, 2, 3].mean # => 2.0
[1, 2, 3].variance.round(4) # => 0.6667
[1, 2, 3].standard_deviation.round(4) # => 0.8165
[1, 2, 3].root_mean_square.round(2) # => 2.16
[1, 2, 3].quadratic_mean.round(2) # => 2.16
[2, 32].geometric_mean # => 8
[40, 60].harmonic_mean.round # => 48
```

4
spec/math/mean.cr

@ -12,8 +12,8 @@ describe Math::Mean do
end
it "test quadratic mean" do
[1, 2, 3, 2].root_mean_square.round(4).should eq(2.1213)
[1, 2, 1, 5, 10, 9, 1, -13, 2].root_mean_square.round(4).should eq(6.549)
[1, 2, 3, 2].quadratic_mean.round(4).should eq(2.1213)
[1, 2, 1, 5, 10, 9, 1, -13, 2].quadratic_mean.round(4).should eq(6.549)
end
it "test geometric mean" do

2
src/lib/math/mean.cr

@ -7,7 +7,7 @@ module Math::Mean
end
# The square root of mean square
def root_mean_square : Float64
def quadratic_mean : Float64
Math.sqrt map { |e| e ** 2 }.mean
end

Loading…
Cancel
Save