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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d6b7a95474412adaa8736a380fe8968e408b04d0
4
- data.tar.gz: 265f1644768fdbad356d91e22c8497a915269f8e
3
+ metadata.gz: 8697da38b49527c038d846912f468f313c8a6b4f
4
+ data.tar.gz: d6f4f88f6ea49ba317cdcab989cee5d8f838b28c
5
5
  SHA512:
6
- metadata.gz: 76edd753a336f38d6b9a01d6ad1773c6a8b11f9e3ed5409b1549f08cdbad363aacc477ce5257c0c4ce83cbc33b856babc5cb66ab4bd4bf54e0b2af2f7586edef
7
- data.tar.gz: d02b18fe2e62018380043d326bdeba2b71cb7564323e06438ab8edca16eba4364a8b17b15c295db4365c17e0c41469db511eed0217b3f7fe3e024abab6452a76
6
+ metadata.gz: 7cfa0c7f1baaaa08af5a3b9858ce04b563ab10c664c5f07813c9f17a2cd2933d35a73254c9d30ef4801854e4bedbe02397888a866f282009d9f5e186b8018418
7
+ data.tar.gz: 0f3733b6b9019d68a52220fbcfbcdd583e9aad45a3a70e2e05e394c6543dcf3d89dc71ce3c6c6b6ddf0512f9b4f9b07586ca97b9df0d623f496a1514488889e2
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: "ruby"
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.2
6
+ - 2.1.3
7
+ script: "bundle exec rspec"
8
+ notifications:
9
+ email: false
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in mathpack.gemspec
3
+ gem "rspec", :group => :test
4
4
  gemspec
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # Mathpack
2
2
  [![Gem Version](https://badge.fury.io/rb/mathpack.svg)](http://badge.fury.io/rb/mathpack)
3
+ [![Build Status](https://travis-ci.org/maxmilan/mathpack.svg?branch=master)](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() #=> -1.778546712802768
44
+ stat.kurtosis() #=> 1.221453287197232
45
45
  stat.skewness() #=> 0.0
46
46
  stat.min() #=> 1
47
47
  stat.max() #=> 6
@@ -1,3 +1,3 @@
1
1
  module Mathpack
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
data/lib/statistics.rb CHANGED
@@ -21,7 +21,7 @@ module Mathpack
21
21
  end
22
22
 
23
23
  def kurtosis
24
- central_moment(4) / variance**2 - 3
24
+ central_moment(4) / variance**2
25
25
  end
26
26
 
27
27
  def max
@@ -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.6
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-26 00:00:00.000000000 Z
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