descriptive_statistics 2.1.0 → 2.2.0

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: 424b78572ef5dbc470842c2c98c582397d19e02c
4
- data.tar.gz: 5fc10328260dbd61fb228cf82db14ce2a2392dca
3
+ metadata.gz: e309fdf859185630fa3f8766b51c32411b748190
4
+ data.tar.gz: 2852dd323dec053aea7afaa813456ee350f13ab1
5
5
  SHA512:
6
- metadata.gz: c8adf2b3c95be69c40b16a7704bf6251f20ce1c10535fabdfba0c9811b5dbe64dcc9625f3c11840d0e37bc3812af26b0d92faf3066f23f4a6a704ebf7ed44e35
7
- data.tar.gz: 79a89003998c2f2ae6bce9f50d530ce7b8917c36064dad2b71d27ca7d9699416b58ee89fc856a774afa95330f660dbafcd3a87b0fc293c614981daa77f357ab3
6
+ metadata.gz: a4d7de2fbb8be9a1b7cfd08e18b643fd7186c1b3914b2b73dd753086e5c22cd47e14e3b03b2933d7aeff9d4a0f6d68034d3402da37f97cfa1892dfef79b39901
7
+ data.tar.gz: cbd99a2b32aa960ae41643dedee7f51dd3d60a1473ba239742b417ee2f3971df29fe9ec0193091d0b5c7b2ad8f9f7aa834a9eb4a83cb1fa487c05fca1306a775
@@ -0,0 +1,11 @@
1
+ module DescriptiveStatistics
2
+
3
+ class << self
4
+
5
+ DescriptiveStatistics.instance_methods.each do |m|
6
+ define_method(m, DescriptiveStatistics.instance_method(m))
7
+ end
8
+
9
+ end
10
+
11
+ end
@@ -1,6 +1,6 @@
1
1
  module DescriptiveStatistics
2
- def mean
3
- values = Support::convert(self)
2
+ def mean(collection = self)
3
+ values = Support::convert(collection)
4
4
  return unless values.size > 0
5
5
 
6
6
  values.sum / values.number
@@ -1,6 +1,6 @@
1
1
  module DescriptiveStatistics
2
- def median
3
- values = Support::convert(self)
2
+ def median(collection = self)
3
+ values = Support::convert(collection)
4
4
  return unless values.size > 0
5
5
 
6
6
  values.percentile(50)
@@ -1,6 +1,6 @@
1
1
  module DescriptiveStatistics
2
- def mode
3
- values = Support::extract(self)
2
+ def mode(collection = self)
3
+ values = Support::extract(collection)
4
4
  return unless values.size > 0
5
5
 
6
6
  values
@@ -1,6 +1,6 @@
1
1
  module DescriptiveStatistics
2
- def number
3
- values = Support::extract(self)
2
+ def number(collection = self)
3
+ values = Support::extract(collection)
4
4
 
5
5
  values.size.to_f
6
6
  end
@@ -1,6 +1,6 @@
1
1
  module DescriptiveStatistics
2
- def percentile(p)
3
- values = Support::convert(self)
2
+ def percentile(p, collection = self)
3
+ values = Support::convert(collection)
4
4
  return unless values.size > 0
5
5
 
6
6
  return values.first unless values.size > 1
@@ -1,7 +1,7 @@
1
1
  module DescriptiveStatistics
2
2
  # percent of cases that are at or below a score
3
- def percentile_rank(p)
4
- values = Support::convert(self)
3
+ def percentile_rank(p, collection = self)
4
+ values = Support::convert(collection)
5
5
  return unless values.size > 0
6
6
 
7
7
  return (((values.sort.rindex{ |x| x <= p } || -1.0) + 1.0)) / values.number * 100.0
@@ -1,6 +1,6 @@
1
1
  module DescriptiveStatistics
2
- def range
3
- values = Support::convert(self)
2
+ def range(collection = self)
3
+ values = Support::convert(collection)
4
4
  return unless values.size > 0
5
5
 
6
6
  values.max - values.min
@@ -11,4 +11,5 @@ require 'descriptive_statistics/percentile_rank.rb'
11
11
  require 'descriptive_statistics/range.rb'
12
12
  require 'descriptive_statistics/descriptive_statistics.rb'
13
13
  require 'descriptive_statistics/stats.rb'
14
+ require 'descriptive_statistics/class_methods.rb'
14
15
 
@@ -1,6 +1,6 @@
1
1
  module DescriptiveStatistics
2
- def standard_deviation
3
- values = Support::convert(self)
2
+ def standard_deviation(collection = self)
3
+ values = Support::convert(collection)
4
4
  return unless values.size > 0
5
5
 
6
6
  Math.sqrt(values.variance)
@@ -1,18 +1,9 @@
1
- require 'forwardable'
1
+ require 'delegate'
2
2
 
3
3
  module DescriptiveStatistics
4
4
 
5
- class Stats
6
- extend Forwardable
7
-
8
- DescriptiveStatistics.instance_methods.each do |m|
9
- def_delegator :@collection, m
10
- end
11
-
12
- def initialize(collection)
13
- @collection = collection.clone.extend(DescriptiveStatistics)
14
- end
15
-
5
+ class Stats < SimpleDelegator
6
+ include DescriptiveStatistics
16
7
  end
17
8
 
18
9
  end
@@ -1,6 +1,6 @@
1
1
  module DescriptiveStatistics
2
- def sum
3
- values = Support::convert(self)
2
+ def sum(collection = self)
3
+ values = Support::convert(collection)
4
4
  return unless values.size > 0
5
5
 
6
6
  return values.inject(:+)
@@ -1,6 +1,6 @@
1
1
  module DescriptiveStatistics
2
- def variance
3
- values = Support::convert(self)
2
+ def variance(collection = self)
3
+ values = Support::convert(collection)
4
4
  return unless values.size > 0
5
5
 
6
6
  mean = values.mean
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: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derrick Parkhurst
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-09-02 00:00:00.000000000 Z
15
+ date: 2014-09-03 00:00:00.000000000 Z
16
16
  dependencies: []
17
17
  description: Adds descriptive statistics methods to Enumerable module for use on collections
18
18
  or Numeric data
@@ -22,6 +22,7 @@ extensions: []
22
22
  extra_rdoc_files: []
23
23
  files:
24
24
  - lib/descriptive_statistics.rb
25
+ - lib/descriptive_statistics/class_methods.rb
25
26
  - lib/descriptive_statistics/descriptive_statistics.rb
26
27
  - lib/descriptive_statistics/enumerable_extension.rb
27
28
  - lib/descriptive_statistics/mean.rb