descriptive-statistics 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZDY1MGYxYzViMzFiNjE2ZjQwZGIyODJiNWRhYzQ5OGNmNzdiMDIxMQ==
5
+ data.tar.gz: !binary |-
6
+ MDk2OWI0ZTkyYjdlNWU4MDNmZDI3ZWQyMzFlNjk0MGE1MzczYWM0Ng==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZWMzOTEwZjQ1NTViODRiODE1ODNiNjhhYWFlN2VlODQxZGM1ZThjOWY4M2Fk
10
+ OGRkNjMyZjk1MWQwOTg1Y2E1OGM5ZDNjMmI1MjdmZmMwZGNhOWQyOGUwYTY1
11
+ YTMzYTAyZGMzYjBmOWFkY2YwYjA3MTMzZDIyMjg2NmY1MGQyODE=
12
+ data.tar.gz: !binary |-
13
+ MDIzZjA0MTA5OGFlNTc5N2E1ZGM2ZGFmNDJlYmM2NDVhZTJmYjNhZWY3ZDY4
14
+ ZDM4NTU0MTBlYjc5NGY2OTI5NDEzZGU3NzMzZmNjNjg2NGFiODA0MjdhYjZm
15
+ OTYzOWU4YjdiMWJkNjk1YmI3YWMwNzdlNGI5M2Q2ODdjYmYzYTI=
Binary file
Binary file
@@ -3,10 +3,15 @@ rvm:
3
3
  - jruby-18mode
4
4
  - jruby-19mode
5
5
  - jruby-head
6
+ - 2.0.0
6
7
  - 1.9.3
7
8
  - 1.9.2
8
9
  - rbx-18mode
9
10
  - rbx-19mode
10
11
  - ruby-head
11
12
  - 1.8.7
12
- - ree
13
+ - ree
14
+
15
+ matrix:
16
+ allow_failures:
17
+ - rvm: ruby-head
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 Julian Tescher
1
+ Copyright (c) 2013 Julian Tescher
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -3,13 +3,19 @@
3
3
  This gem calculates descriptive statistics including measures of central tendency (e.g. mean, median mode), dispersion
4
4
  (e.g. range, and quartiles), and spread (e.g variance and standard deviation).
5
5
 
6
- Tested against ruby 1.8.7, 1.9.2, 1.9.3, ruby-head, jruby-18mode, jruby-19mode, jruby-head, rbx-18mode, rbx-19mode, and
7
- ree
6
+ Tested against ruby 1.8.7, 1.9.2, 1.9.3, 2.0.0, ruby-head, jruby-18mode, jruby-19mode, jruby-head, rbx-18mode,
7
+ rbx-19mode, and ree
8
8
 
9
9
  [![Build Status](https://secure.travis-ci.org/jtescher/descriptive-statistics.png)]
10
10
  (http://travis-ci.org/jtescher/descriptive-statistics)
11
- [![Dependency Status](https://gemnasium.com/jtescher/descriptive-statistics.png)](https://gemnasium.com/jtescher/descriptive-statistics)
12
- [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/jtescher/descriptive-statistics)
11
+ [![Dependency Status](https://gemnasium.com/jtescher/descriptive-statistics.png)]
12
+ (https://gemnasium.com/jtescher/descriptive-statistics)
13
+ [![Code Climate](https://codeclimate.com/github/jtescher/descriptive-statistics.png)]
14
+ (https://codeclimate.com/github/jtescher/descriptive-statistics)
15
+ [![Gem Version](https://badge.fury.io/rb/descriptive-statistics.png)]
16
+ (http://badge.fury.io/rb/descriptive-statistics)
17
+ [![Coverage Status](https://coveralls.io/repos/jtescher/descriptive-statistics/badge.png)]
18
+ (https://coveralls.io/r/jtescher/descriptive-statistics)
13
19
  ## Installation
14
20
 
15
21
  Add this line to your application's Gemfile:
@@ -49,6 +55,7 @@ stats.value_from_percentile(60) #=> 3
49
55
  stats = DescriptiveStatistics::Stats.new([1,1,2,3,10])
50
56
  stats.variance #=> 14.299999999999999
51
57
  stats.standard_deviation #=> 3.7815340802378072
58
+ stats.relative_standard_deviation #=> 99.47961485463391
52
59
  ```
53
60
 
54
61
  ### Other Measures:
@@ -66,12 +73,12 @@ If you want to monkey patch descriptive statistics methods into Enumerable, you
66
73
  require 'descriptive-statistics'
67
74
 
68
75
  module Enumerable
69
- include DescriptiveStatistics::AllMethods
76
+ include DescriptiveStatistics
70
77
 
71
78
  # Warning: hacky evil meta programming. Required because classes that have already included
72
79
  # Enumerable will not otherwise inherit the statistics methods.
73
80
  DescriptiveStatistics.instance_methods.each do |m|
74
- define_method(m, DescriptiveStatistics::AllMethods.instance_method(m))
81
+ define_method(m, DescriptiveStatistics.instance_method(m))
75
82
  end
76
83
  end
77
84
  ```
@@ -12,12 +12,19 @@ Gem::Specification.new do |gem|
12
12
  gem.summary = %q{Simply calculate descriptive statistics such as measures of central tendency (e.g. mean,median,
13
13
  mode), dispersion (e.g. range and quartiles), and spread (e.g variance and standard deviation)}
14
14
  gem.homepage = "https://github.com/jtescher/descriptive-statistics"
15
+ gem.signing_key = File.expand_path('~/.ssh/gem-private_key.pem') if $0 =~ /gem\z/
16
+ gem.cert_chain = ['gem-public_cert.pem']
17
+ gem.license = "MIT"
15
18
 
16
19
  gem.files = `git ls-files`.split($/)
17
20
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
21
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
22
  gem.require_paths = ["lib"]
20
23
 
21
- gem.add_development_dependency "rspec", "~> 2.13.0"
22
- gem.add_development_dependency "rake", "~> 10.0.3"
24
+ gem.add_development_dependency "rspec", "~> 2.14.1"
25
+ gem.add_development_dependency "rake", "~> 10.1.0"
26
+ if RUBY_VERSION > "1.9"
27
+ gem.add_development_dependency "simplecov", "~> 0.7.1"
28
+ gem.add_development_dependency "coveralls", "~> 0.6.8"
29
+ end
23
30
  end
@@ -0,0 +1,19 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDKjCCAhKgAwIBAgIBADANBgkqhkiG9w0BAQUFADA7MQ0wCwYDVQQDDAR5b3Vy
3
+ MRUwEwYKCZImiZPyLGQBGRYFZW1haWwxEzARBgoJkiaJk/IsZAEZFgNjb20wHhcN
4
+ MTMwNjE0MTkxMjQ4WhcNMTQwNjE0MTkxMjQ4WjA7MQ0wCwYDVQQDDAR5b3VyMRUw
5
+ EwYKCZImiZPyLGQBGRYFZW1haWwxEzARBgoJkiaJk/IsZAEZFgNjb20wggEiMA0G
6
+ CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC9WjvJinWV7h9VeLlf4+yHxr1LF/8/
7
+ HHFCKYEs/ZrUJLrpmuUWUrkgpwIbV5FUvqkXoCcCvR2z65lAONZtdvg3ygBBXfl7
8
+ rQaNb/EMMzulmf26ztAtUP0Ipaz0pX/qlzDLkDkhXxUB1rUcxuZ2Rif0HsOtQO5d
9
+ MzQfREsYDtWMileLxcImCxtoE5r+tG2sbJ72gxP0QygAwL+mke//C0wPVCBC9zI2
10
+ fwhZmTD2dmyx0JW8C0YR+38kqtMldCcIQOPRH6ue/JAyfxaosYyNLK5zuUoW1MSR
11
+ l1PMWb3fEDXprbnku496f026FAgDn8TFsWDFw+KhHwTgIYASbgopYqWTAgMBAAGj
12
+ OTA3MAkGA1UdEwQCMAAwHQYDVR0OBBYEFM0KCQLMiOjnsL1TEu5IFFRCar4CMAsG
13
+ A1UdDwQEAwIEsDANBgkqhkiG9w0BAQUFAAOCAQEAscW33q8g0jLkAE8jZnIYjbO3
14
+ hhNpSyXO1JmJEbm5q9v5rDqhj8RTbdd100tFwGc2tIViR9edQ8Z72s9gEAdU6N4P
15
+ HpoYcNOqET8Fqs+o16lbk74on6Gv9S5LZjBQ1UuIqDbENuTzogxY25Yx5dIGHyIo
16
+ 7rzorf4e4KCNFw19BG5M3ijlMvciSGxIPbmJoaSa7m62sudGr3CrEpRgMZBvp1Ea
17
+ ILaPiI1PhVurfov2y0+YT0rbOrv4cWoBWsZ+aww2iSNC5XFhA/8xsK0BltYRF9nP
18
+ HA41UtDxrJkHL3N1z8gPMXSrFT41FR2wgk8+l14P+7g1UTPid2EIwft2xObFeA==
19
+ -----END CERTIFICATE-----
@@ -2,7 +2,7 @@ module DescriptiveStatistics
2
2
  module CentralTendency
3
3
  def sum(identity = 0, &block)
4
4
  if block_given?
5
- map(&block).sum(identity)
5
+ DescriptiveStatistics::Stats.new(map(&block)).sum(identity)
6
6
  else
7
7
  inject(:+) || identity
8
8
  end
@@ -17,6 +17,11 @@ module DescriptiveStatistics
17
17
  Math.sqrt(variance)
18
18
  end
19
19
 
20
+ def relative_standard_deviation
21
+ return if length < 1
22
+ (population_standard_deviation / mean) * 100.0
23
+ end
24
+
20
25
  def population_standard_deviation
21
26
  return if length < 2
22
27
  Math.sqrt(population_variance)
@@ -1,3 +1,3 @@
1
1
  module DescriptiveStatistics
2
- VERSION = "2.0.0"
2
+ VERSION = "2.1.0"
3
3
  end
@@ -6,6 +6,10 @@ describe DescriptiveStatistics::CentralTendency do
6
6
  DescriptiveStatistics::Stats.new([1,2,6]).sum.should == 9
7
7
  end
8
8
 
9
+ it 'allows a block to be passed' do
10
+ DescriptiveStatistics::Stats.new([1,2,6]).sum{ |x| x * 2 }.should == 18
11
+ end
12
+
9
13
  it 'returns 0 if empty' do
10
14
  DescriptiveStatistics::Stats.new([]).sum.should == 0
11
15
  end
@@ -44,6 +48,10 @@ describe DescriptiveStatistics::CentralTendency do
44
48
  DescriptiveStatistics::Stats.new([1,2,3]).mode.should be_nil
45
49
  end
46
50
 
51
+ it 'returns the first value if there is only one' do
52
+ DescriptiveStatistics::Stats.new([3.5]).mode.should == 3.5
53
+ end
54
+
47
55
  it 'returns nil if empty' do
48
56
  DescriptiveStatistics::Stats.new([]).mode.should be_nil
49
57
  end
@@ -31,6 +31,21 @@ describe DescriptiveStatistics::Spread do
31
31
  end
32
32
  end
33
33
 
34
+ describe '#relative_standard_deviation' do
35
+ it 'returns 0 for constant values' do
36
+ DescriptiveStatistics::Stats.new([100, 100, 100]).relative_standard_deviation.should == 0
37
+ end
38
+
39
+ it 'returns the population_standard_deviation divided by the mean * 100' do
40
+ DescriptiveStatistics::Stats.new([90, 100, 110]).relative_standard_deviation.should be_within(0.01).of(8.16)
41
+ DescriptiveStatistics::Stats.new([1, 5, 6, 8, 10, 40, 65, 88]).relative_standard_deviation.should be_within(0.01).of(110.41)
42
+ end
43
+
44
+ it 'returns nil if empty' do
45
+ DescriptiveStatistics::Stats.new([]).relative_standard_deviation.should be_nil
46
+ end
47
+ end
48
+
34
49
  describe '#population_standard_deviation' do
35
50
  it 'returns the square root of the population_variance' do
36
51
  DescriptiveStatistics::Stats.new([1,2,6]).population_standard_deviation.should == 2.160246899469287
@@ -1,2 +1,12 @@
1
+ begin
2
+ require 'simplecov'
3
+ require 'coveralls'
4
+ #SimpleCov.formatter = Coveralls::SimpleCov::Formatter
5
+ SimpleCov.start
6
+ rescue LoadError
7
+ # Simplecov and coveralls do not work in Ruby < 1.9
8
+ end
9
+
10
+
1
11
  $LOAD_PATH << File.expand_path('../../lib', __FILE__)
2
12
  require 'descriptive-statistics'
metadata CHANGED
@@ -1,48 +1,98 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: descriptive-statistics
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
5
- prerelease:
4
+ version: 2.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Julian Tescher
9
8
  autorequire:
10
9
  bindir: bin
11
- cert_chain: []
12
- date: 2013-03-22 00:00:00.000000000 Z
10
+ cert_chain:
11
+ - !binary |-
12
+ LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURLakNDQWhLZ0F3SUJB
13
+ Z0lCQURBTkJna3Foa2lHOXcwQkFRVUZBREE3TVEwd0N3WURWUVFEREFSNWIz
14
+ VnkKTVJVd0V3WUtDWkltaVpQeUxHUUJHUllGWlcxaGFXd3hFekFSQmdvSmtp
15
+ YUprL0lzWkFFWkZnTmpiMjB3SGhjTgpNVE13TmpFME1Ua3hNalE0V2hjTk1U
16
+ UXdOakUwTVRreE1qUTRXakE3TVEwd0N3WURWUVFEREFSNWIzVnlNUlV3CkV3
17
+ WUtDWkltaVpQeUxHUUJHUllGWlcxaGFXd3hFekFSQmdvSmtpYUprL0lzWkFF
18
+ WkZnTmpiMjB3Z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CklMYVBpSTFQaFZ1cmZvdjJ5MCtZVDByYk9ydjRjV29C
35
+ V3NaK2F3dzJpU05DNVhGaEEvOHhzSzBCbHRZUkY5blAKSEE0MVV0RHhySmtI
36
+ TDNOMXo4Z1BNWFNyRlQ0MUZSMndnazgrbDE0UCs3ZzFVVFBpZDJFSXdmdDJ4
37
+ T2JGZUE9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
38
+ date: 2013-09-12 00:00:00.000000000 Z
13
39
  dependencies:
14
40
  - !ruby/object:Gem::Dependency
15
41
  name: rspec
16
42
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
43
  requirements:
19
44
  - - ~>
20
45
  - !ruby/object:Gem::Version
21
- version: 2.13.0
46
+ version: 2.14.1
22
47
  type: :development
23
48
  prerelease: false
24
49
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
50
  requirements:
27
51
  - - ~>
28
52
  - !ruby/object:Gem::Version
29
- version: 2.13.0
53
+ version: 2.14.1
30
54
  - !ruby/object:Gem::Dependency
31
55
  name: rake
32
56
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
57
  requirements:
35
58
  - - ~>
36
59
  - !ruby/object:Gem::Version
37
- version: 10.0.3
60
+ version: 10.1.0
38
61
  type: :development
39
62
  prerelease: false
40
63
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
64
  requirements:
43
65
  - - ~>
44
66
  - !ruby/object:Gem::Version
45
- version: 10.0.3
67
+ version: 10.1.0
68
+ - !ruby/object:Gem::Dependency
69
+ name: simplecov
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ version: 0.7.1
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ~>
80
+ - !ruby/object:Gem::Version
81
+ version: 0.7.1
82
+ - !ruby/object:Gem::Dependency
83
+ name: coveralls
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ~>
87
+ - !ruby/object:Gem::Version
88
+ version: 0.6.8
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ~>
94
+ - !ruby/object:Gem::Version
95
+ version: 0.6.8
46
96
  description: Descriptive Statistics Calculator
47
97
  email:
48
98
  - virulent@gmail.com
@@ -57,6 +107,7 @@ files:
57
107
  - README.md
58
108
  - Rakefile
59
109
  - descriptive-statistics.gemspec
110
+ - gem-public_cert.pem
60
111
  - lib/descriptive-statistics.rb
61
112
  - lib/descriptive-statistics/all-methods.rb
62
113
  - lib/descriptive-statistics/central-tendency.rb
@@ -74,34 +125,28 @@ files:
74
125
  - spec/lib/descriptive_statistics_spec.rb
75
126
  - spec/spec_helper.rb
76
127
  homepage: https://github.com/jtescher/descriptive-statistics
77
- licenses: []
128
+ licenses:
129
+ - MIT
130
+ metadata: {}
78
131
  post_install_message:
79
132
  rdoc_options: []
80
133
  require_paths:
81
134
  - lib
82
135
  required_ruby_version: !ruby/object:Gem::Requirement
83
- none: false
84
136
  requirements:
85
137
  - - ! '>='
86
138
  - !ruby/object:Gem::Version
87
139
  version: '0'
88
- segments:
89
- - 0
90
- hash: -3484178174301179474
91
140
  required_rubygems_version: !ruby/object:Gem::Requirement
92
- none: false
93
141
  requirements:
94
142
  - - ! '>='
95
143
  - !ruby/object:Gem::Version
96
144
  version: '0'
97
- segments:
98
- - 0
99
- hash: -3484178174301179474
100
145
  requirements: []
101
146
  rubyforge_project:
102
- rubygems_version: 1.8.25
147
+ rubygems_version: 2.0.7
103
148
  signing_key:
104
- specification_version: 3
149
+ specification_version: 4
105
150
  summary: Simply calculate descriptive statistics such as measures of central tendency
106
151
  (e.g. mean,median, mode), dispersion (e.g. range and quartiles), and spread (e.g
107
152
  variance and standard deviation)
Binary file