ministat 1.1.0 → 1.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.
File without changes
data/Rakefile CHANGED
@@ -1,18 +1,15 @@
1
- # -*- ruby -*-
2
-
3
- require 'rubygems'
4
- require 'hoe'
1
+ require 'rake/gempackagetask'
5
2
  require './lib/ministat.rb'
6
3
 
7
- Hoe.new('ministat', MiniStat::VERSION) do |p|
8
- p.rubyforge_name = 'ministat'
4
+ spec = Gem::Specification.new do |p|
5
+ p.version = MiniStat::VERSION
6
+ p.name = 'ministat'
9
7
  p.author = 'Dean Hudson'
10
8
  p.email = 'dean@ero.com'
11
9
  p.summary = 'A small and simple library to generate statistical info on single-variable datasets.'
12
- p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
13
- p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
14
- p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
15
- p.remote_rdoc_dir = ''
10
+ p.description = File.read(File.join(File.dirname(__FILE__), 'README'))
11
+ p.requirements = ['An eye for data and a strong will to live']
12
+ p.has_rdoc = true
13
+ p.files = Dir['**/**']
16
14
  end
17
-
18
- # vim: syntax=Ruby
15
+ Rake::GemPackageTask.new(spec).define
@@ -1,7 +1,7 @@
1
1
  require 'mathn'
2
2
 
3
3
  module MiniStat
4
- VERSION = '1.1.0'
4
+ VERSION = '1.2.0'
5
5
  class Data
6
6
  attr_reader :data
7
7
 
@@ -53,7 +53,7 @@ module MiniStat
53
53
  @q3 ||= median(partition(median(@data), @data)[:high])
54
54
  end
55
55
 
56
- # Interquartile range, ie the middle 50% of the data.
56
+ # Interquartile range, ie, the middle 50% of the data.
57
57
  def iqr
58
58
  @iqr ||= q3 - q1
59
59
  end
@@ -71,7 +71,8 @@ module MiniStat
71
71
  @mean = (data.inject(0) {|i,j| i += j}) / data.size
72
72
  end
73
73
 
74
- # Computes mode and a histogram.
74
+ # Computes mode and generates a histogram (for free!).
75
+ # (We needed it anyway).
75
76
  def mode
76
77
  @hist ||= {}
77
78
  @max_freq ||= 0
@@ -113,6 +114,23 @@ module MiniStat
113
114
  @data.size.to_f / (@data.inject(0) {|i,j| i += (1.0/j)})
114
115
  end
115
116
 
117
+ # Put the histogram into a string if we have it
118
+ def hist
119
+ str = ''
120
+ if defined? @hist
121
+ # this is a textbook example of how to lie with statistics...
122
+ # TODO: iterate over a range rather than @hist.keys--a histogram
123
+ # produced out of the keys won't properly represent flat spots
124
+ # with no data. or something like that. do as i say, not as i do.
125
+ @hist.keys do |k|
126
+ str << "[#{k}\t] "
127
+ 1.upto(@hist[k].to_i) {|i| str << "*"}
128
+ str << "\n"
129
+ end
130
+ end
131
+ str
132
+ end
133
+
116
134
  # Return a string with statisical info about a dataset.
117
135
  def to_s
118
136
  <<-DATA_STR
metadata CHANGED
@@ -1,92 +1,134 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ministat
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
5
- platform: ""
4
+ hash: 31
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 2
9
+ - 0
10
+ version: 1.2.0
11
+ platform: ruby
6
12
  authors:
7
13
  - Dean Hudson
8
14
  autorequire:
9
15
  bindir: bin
10
- cert_chain:
11
- - |
12
- -----BEGIN CERTIFICATE-----
13
- MIIDJjCCAg6gAwIBAgIBADANBgkqhkiG9w0BAQUFADA5MQ0wCwYDVQQDDARkZWFu
14
- MRMwEQYKCZImiZPyLGQBGRYDZXJvMRMwEQYKCZImiZPyLGQBGRYDY29tMB4XDTA3
15
- MTExMTIxMDUyOFoXDTA4MTExMDIxMDUyOFowOTENMAsGA1UEAwwEZGVhbjETMBEG
16
- CgmSJomT8ixkARkWA2VybzETMBEGCgmSJomT8ixkARkWA2NvbTCCASIwDQYJKoZI
17
- hvcNAQEBBQADggEPADCCAQoCggEBALaFLGaIMK1QdFGuO8RfaYTiSwac2GHdEaMb
18
- p9s8n0zf+tpRMY8NigtrEnJCEvUSMMRhQ1kfxxFYBNbzKh281utzxPmmP7kGFfRD
19
- e9EW1ZTrDPC564ZEE15blpbMEi2aIwLc2BMajLkAm2szjQJcvknwnxzkKPI1qFTb
20
- 8EsDY0rJbgXv9agthbgeXCplg16LKxUKjBYvsEWyiE+DgogIMrgJ3nlR2MOCufLm
21
- gIrhOH0+RUbhR6c8D+KMkb/ecMhuYJ4gK30C2013J7TM7cPj//9Rb0vrmFXzV3ce
22
- qOESBIu1Ig2Ni9n/otr/bHvkKxdGU7SVeu3uvJX++iKfEMpDleUCAwEAAaM5MDcw
23
- CQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFK/N1WFuLd0IX64NCuNS
24
- EwukScaTMA0GCSqGSIb3DQEBBQUAA4IBAQAUNmyZYE62GPVkxZnrjH+rI3YkcTYK
25
- fCWGy67mPo1utCKptzki7rHcpD0d6tlGKqBqkBis1HgIBSrxRV7oEK4UYvbd5jN3
26
- yUoj670OYuNJpYNnX6Iutv3dEwpcK92zGhTxQqKEjhjvtLFCsQQ8kB2pD+luxPzL
27
- XHfIWVfPxvVErhBKL2BulZoHJeR4af0ycfZjDAbIbuBoYtnyN6Ao8pI3fctd83DU
28
- UkMkLYctGf1HBjckiVT2aIOnbMiq2ZbsjXZil3LUBifYtRXJFxphEH/PohNttnlh
29
- 0exsBRogOA9ZeNEwstSUQ4t1X3FLmOpayH1iM25aKmmaGbCeA6TVEd/5
30
- -----END CERTIFICATE-----
16
+ cert_chain: []
31
17
 
32
- date: 2008-01-08 00:00:00 -08:00
18
+ date: 2010-06-18 00:00:00 -07:00
33
19
  default_executable:
34
- dependencies:
35
- - !ruby/object:Gem::Dependency
36
- name: hoe
37
- version_requirement:
38
- version_requirements: !ruby/object:Gem::Requirement
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- version: 1.3.0
43
- version:
44
- description: "== FEATURES/PROBLEMS: * Pure Ruby * It's small and simple * It's probably good enough * I haven't profiled it against large data sets * Naive median implementation requires a sort, but it could be done in linear time. Patches welcome. * Missing tests for harmonic and geometric mean -- the stats package I was generating test data with didn't have them. == SYNOPSIS: require 'ministat' data = [1,2,3,4,5,6,7,7,6,5,4,4] puts MiniStat::Data.new(data).to_s"
20
+ dependencies: []
21
+
22
+ description: |
23
+ ministat
24
+ by Dean Hudson
25
+ ero.com
26
+
27
+ == DESCRIPTION:
28
+
29
+ This is a simple package that generates simple statistical info on
30
+ numerical data sets of a single variable. It's nothing too fancy, but
31
+ maybe just enough to coat your numbers with a thin layer of science. Or,
32
+ at least to get you thinking about what it may take to do so.
33
+
34
+ == FEATURES/PROBLEMS:
35
+
36
+ * Pure Ruby
37
+ * It's small and simple
38
+ * It's probably good enough
39
+ * I haven't profiled it against large data sets
40
+ * Naive median implementation requires a sort, but it could be done in linear time. Patches welcome.
41
+ * Missing tests for harmonic and geometric mean -- the stats package I was generating test data with didn't have them.
42
+
43
+ == SYNOPSIS:
44
+
45
+ require 'ministat'
46
+
47
+ data = [1,2,3,4,5,6,7,7,6,5,4,4]
48
+ puts MiniStat::Data.new(data).to_s
49
+
50
+ == REQUIREMENTS:
51
+
52
+ Hoe
53
+
54
+ == INSTALL:
55
+
56
+ sudo gem install ministat
57
+
58
+ == LICENSE:
59
+
60
+ (The MIT License)
61
+
62
+ Copyright (c) 2007 Dean Hudson
63
+
64
+ Permission is hereby granted, free of charge, to any person obtaining
65
+ a copy of this software and associated documentation files (the
66
+ 'Software'), to deal in the Software without restriction, including
67
+ without limitation the rights to use, copy, modify, merge, publish,
68
+ distribute, sublicense, and/or sell copies of the Software, and to
69
+ permit persons to whom the Software is furnished to do so, subject to
70
+ the following conditions:
71
+
72
+ The above copyright notice and this permission notice shall be
73
+ included in all copies or substantial portions of the Software.
74
+
75
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
76
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
77
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
78
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
79
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
80
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
81
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
82
+
45
83
  email: dean@ero.com
46
- executables:
47
- - ministat
84
+ executables: []
85
+
48
86
  extensions: []
49
87
 
50
- extra_rdoc_files:
51
- - History.txt
52
- - Manifest.txt
53
- - README.txt
88
+ extra_rdoc_files: []
89
+
54
90
  files:
55
91
  - History.txt
56
- - Manifest.txt
57
- - README.txt
58
- - Rakefile
59
- - bin/ministat
60
92
  - lib/ministat.rb
61
- - test/data/1.dat
62
- - test/data/2.dat
63
93
  - test/test_ministat.rb
94
+ - test/data/2.dat
95
+ - test/data/1.dat
96
+ - Rakefile
97
+ - README
98
+ - bin/ministat
64
99
  has_rdoc: true
65
- homepage: " by Dean Hudson"
100
+ homepage:
101
+ licenses: []
102
+
66
103
  post_install_message:
67
- rdoc_options:
68
- - --main
69
- - README.txt
104
+ rdoc_options: []
105
+
70
106
  require_paths:
71
107
  - lib
72
108
  required_ruby_version: !ruby/object:Gem::Requirement
109
+ none: false
73
110
  requirements:
74
111
  - - ">="
75
112
  - !ruby/object:Gem::Version
113
+ hash: 3
114
+ segments:
115
+ - 0
76
116
  version: "0"
77
- version:
78
117
  required_rubygems_version: !ruby/object:Gem::Requirement
118
+ none: false
79
119
  requirements:
80
120
  - - ">="
81
121
  - !ruby/object:Gem::Version
122
+ hash: 3
123
+ segments:
124
+ - 0
82
125
  version: "0"
83
- version:
84
- requirements: []
85
-
86
- rubyforge_project: ministat
87
- rubygems_version: 0.9.5
126
+ requirements:
127
+ - An eye for data and a strong will to live
128
+ rubyforge_project:
129
+ rubygems_version: 1.3.7
88
130
  signing_key:
89
- specification_version: 2
131
+ specification_version: 3
90
132
  summary: A small and simple library to generate statistical info on single-variable datasets.
91
- test_files:
92
- - test/test_ministat.rb
133
+ test_files: []
134
+
data.tar.gz.sig DELETED
Binary file
@@ -1,9 +0,0 @@
1
- History.txt
2
- Manifest.txt
3
- README.txt
4
- Rakefile
5
- bin/ministat
6
- lib/ministat.rb
7
- test/data/1.dat
8
- test/data/2.dat
9
- test/test_ministat.rb
metadata.gz.sig DELETED
Binary file