descriptive-statistics 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@ class DescriptiveStatistics
|
|
2
2
|
module Shape
|
3
3
|
def skewness
|
4
4
|
return if length < 1
|
5
|
+
return 0 if length == 1
|
5
6
|
sum_cubed_deviation = inject(0) {|sum, value| sum + (value - mean) ** 3}
|
6
7
|
cubed_standard_deviation = standard_deviation ** 3
|
7
8
|
sum_cubed_deviation / ((length - 1) * cubed_standard_deviation.to_f)
|
@@ -9,6 +10,7 @@ class DescriptiveStatistics
|
|
9
10
|
|
10
11
|
def kurtosis
|
11
12
|
return if length < 1
|
13
|
+
return 0 if length == 1
|
12
14
|
sum_quarted_deviation = inject(0) {|sum, value| sum + (value - mean) ** 4}
|
13
15
|
quarted_standard_deviation = standard_deviation ** 4
|
14
16
|
sum_quarted_deviation / ((length - 1) * quarted_standard_deviation.to_f)
|
@@ -10,6 +10,10 @@ describe DescriptiveStatistics::Shape do
|
|
10
10
|
DescriptiveStatistics.new([50,10,1,1,1]).skewness.should == 1.2374536958450908
|
11
11
|
end
|
12
12
|
|
13
|
+
it 'returns 0 if only one element' do
|
14
|
+
DescriptiveStatistics.new([1]).skewness.should == 0
|
15
|
+
end
|
16
|
+
|
13
17
|
it 'returns nil if empty' do
|
14
18
|
DescriptiveStatistics.new([]).skewness.should be_nil
|
15
19
|
end
|
@@ -24,6 +28,10 @@ describe DescriptiveStatistics::Shape do
|
|
24
28
|
DescriptiveStatistics.new([50,10,1,1,1]).kurtosis.should == 2.45740139974872
|
25
29
|
end
|
26
30
|
|
31
|
+
it 'returns 0 if only one element' do
|
32
|
+
DescriptiveStatistics.new([1]).kurtosis.should == 0
|
33
|
+
end
|
34
|
+
|
27
35
|
it 'returns nil if empty' do
|
28
36
|
DescriptiveStatistics.new([]).kurtosis.should be_nil
|
29
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: descriptive-statistics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -82,7 +82,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
82
82
|
version: '0'
|
83
83
|
segments:
|
84
84
|
- 0
|
85
|
-
hash: -
|
85
|
+
hash: -3506480406568559823
|
86
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
87
|
none: false
|
88
88
|
requirements:
|
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
91
|
version: '0'
|
92
92
|
segments:
|
93
93
|
- 0
|
94
|
-
hash: -
|
94
|
+
hash: -3506480406568559823
|
95
95
|
requirements: []
|
96
96
|
rubyforge_project:
|
97
97
|
rubygems_version: 1.8.24
|