mathpack 0.0.6 → 0.0.7
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.
- checksums.yaml +4 -4
- data/.travis.yml +9 -0
- data/Gemfile +1 -1
- data/README.md +3 -3
- data/lib/mathpack/version.rb +1 -1
- data/lib/statistics.rb +1 -1
- data/spec/statistics_spec.rb +63 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8697da38b49527c038d846912f468f313c8a6b4f
|
4
|
+
data.tar.gz: d6f4f88f6ea49ba317cdcab989cee5d8f838b28c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cfa0c7f1baaaa08af5a3b9858ce04b563ab10c664c5f07813c9f17a2cd2933d35a73254c9d30ef4801854e4bedbe02397888a866f282009d9f5e186b8018418
|
7
|
+
data.tar.gz: 0f3733b6b9019d68a52220fbcfbcdd583e9aad45a3a70e2e05e394c6543dcf3d89dc71ce3c6c6b6ddf0512f9b4f9b07586ca97b9df0d623f496a1514488889e2
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# Mathpack
|
2
2
|
[](http://badge.fury.io/rb/mathpack)
|
3
|
+
[](https://travis-ci.org/maxmilan/mathpack)
|
3
4
|
|
4
|
-
This gem includes collection of mathematical methods
|
5
|
+
This gem includes a collection of mathematical methods
|
5
6
|
|
6
7
|
## Installation
|
7
8
|
|
@@ -27,7 +28,6 @@ Gem `mathpack` allows to count statistical functions throught `Statistics` class
|
|
27
28
|
- **kurtosis** - returns a kurtosis
|
28
29
|
- **min** - returns the minimal element of series
|
29
30
|
- **max** - returns the maxinal element of series
|
30
|
-
- **number** - returns a number of elements in array
|
31
31
|
- **raw_moment** - returns the *nth* raw moment of series
|
32
32
|
- **central_moment** - returns the *nth* central moment of series
|
33
33
|
- **empirical_cdf** - returns *empirical distribution function* value in some point
|
@@ -41,7 +41,7 @@ stat = Mathpack::Statistics.new([1, 2, 5, 6])
|
|
41
41
|
stat.number() #=> 4
|
42
42
|
stat.mean() #=> 3.5
|
43
43
|
stat.variance() #=> 4.25
|
44
|
-
stat.kurtosis() #=>
|
44
|
+
stat.kurtosis() #=> 1.221453287197232
|
45
45
|
stat.skewness() #=> 0.0
|
46
46
|
stat.min() #=> 1
|
47
47
|
stat.max() #=> 6
|
data/lib/mathpack/version.rb
CHANGED
data/lib/statistics.rb
CHANGED
@@ -0,0 +1,63 @@
|
|
1
|
+
describe 'Statistics' do
|
2
|
+
require 'statistics'
|
3
|
+
|
4
|
+
context "calculated using class methods" do
|
5
|
+
|
6
|
+
let(:data) { [1,5,4,2,3,4,5,7,2,7] }
|
7
|
+
let(:stat) { Mathpack::Statistics.new(data) }
|
8
|
+
|
9
|
+
it "calculates the number" do
|
10
|
+
expect(stat.number).to eql(10)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "calculates the mean" do
|
14
|
+
expect(stat.mean).to eql(4.0)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "calculates the variance" do
|
18
|
+
expect(stat.variance).to eql(3.8)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "calculates the skewness" do
|
22
|
+
expect(stat.skewness).to eql(0.16199658190818222)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "calculates the kurtosis" do
|
26
|
+
expect(stat.kurtosis).to eql(1.925207756232687)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "calculates the minimal element" do
|
30
|
+
expect(stat.min).to eql(1)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "calculates maximal element" do
|
34
|
+
expect(stat.max).to eql(7)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "calculates first raw moment equal to mean" do
|
38
|
+
expect(stat.raw_moment(1)).to eql(stat.mean)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "calculates second central moment equal to variance" do
|
42
|
+
expect(stat.central_moment(2)).to eql(stat.variance)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "calculates raw moment" do
|
46
|
+
expect(stat.raw_moment(3)).to eql(110.8)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "calculates central moment" do
|
50
|
+
expect(stat.central_moment(5)).to eql(18.0)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "calculates empirical cdf" do
|
54
|
+
expect(stat.empirical_cdf(stat.min - 0.1)).to eql(0.0)
|
55
|
+
expect(stat.empirical_cdf(stat.max + 0.1)).to eql(1.0)
|
56
|
+
expect(stat.empirical_cdf(stat.mean)).to eql(0.4)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "calculates empirical pdf" do
|
60
|
+
expect(stat.empirical_pdf(stat.mean)).to eql(0.1882412842233359)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mathpack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- maxmilan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -46,6 +46,7 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- ".gitignore"
|
49
|
+
- ".travis.yml"
|
49
50
|
- Gemfile
|
50
51
|
- LICENSE.txt
|
51
52
|
- README.md
|
@@ -54,6 +55,7 @@ files:
|
|
54
55
|
- lib/mathpack/version.rb
|
55
56
|
- lib/statistics.rb
|
56
57
|
- mathpack.gemspec
|
58
|
+
- spec/statistics_spec.rb
|
57
59
|
homepage: ''
|
58
60
|
licenses:
|
59
61
|
- MIT
|
@@ -78,4 +80,5 @@ rubygems_version: 2.2.2
|
|
78
80
|
signing_key:
|
79
81
|
specification_version: 4
|
80
82
|
summary: Summary
|
81
|
-
test_files:
|
83
|
+
test_files:
|
84
|
+
- spec/statistics_spec.rb
|