rstats 0.0.3 → 0.0.4
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.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/{License.txt → LICENSE} +2 -2
- data/README.rdoc +18 -0
- data/Rakefile +53 -4
- data/VERSION +1 -0
- data/lib/rstats.rb +6 -6
- data/test/helper.rb +10 -0
- data/test/test_rstats.rb +3 -37
- metadata +23 -39
- data/History.txt +0 -4
- data/Manifest.txt +0 -20
- data/PostInstall.txt +0 -1
- data/README.txt +0 -69
- data/config/hoe.rb +0 -73
- data/config/requirements.rb +0 -15
- data/lib/rstats/version.rb +0 -9
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/script/txt2html +0 -82
- data/setup.rb +0 -1585
- data/tasks/deployment.rake +0 -34
- data/tasks/environment.rake +0 -7
- data/tasks/website.rake +0 -17
- data/test/test_helper.rb +0 -2
data/.document
ADDED
data/.gitignore
ADDED
data/{License.txt → LICENSE}
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c)
|
1
|
+
Copyright (c) 2009 Jimmy Baker
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
17
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
19
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
= rstats
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but
|
13
|
+
bump version in a commit by itself I can ignore when I pull)
|
14
|
+
* Send me a pull request. Bonus points for topic branches.
|
15
|
+
|
16
|
+
== Copyright
|
17
|
+
|
18
|
+
Copyright (c) 2009 Jimmy Baker. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1,4 +1,53 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
|
4
|
-
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "rstats"
|
8
|
+
gem.summary = %Q{Adds statistical helper methods like mean, median, mode, skewness, etc. to ruby's array class.}
|
9
|
+
gem.description = %Q{Adds statistical helper methods like mean, median, mode, skewness, etc. to ruby's array class.}
|
10
|
+
gem.email = "jimmybaker@me.com"
|
11
|
+
gem.homepage = "http://github.com/jumzies/rstats"
|
12
|
+
gem.authors = ["Jimmy Baker"]
|
13
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
Jeweler::GemcutterTasks.new
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'rake/testtask'
|
22
|
+
Rake::TestTask.new(:test) do |test|
|
23
|
+
test.libs << 'lib' << 'test'
|
24
|
+
test.pattern = 'test/**/test_*.rb'
|
25
|
+
test.verbose = true
|
26
|
+
end
|
27
|
+
|
28
|
+
begin
|
29
|
+
require 'rcov/rcovtask'
|
30
|
+
Rcov::RcovTask.new do |test|
|
31
|
+
test.libs << 'test'
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
rescue LoadError
|
36
|
+
task :rcov do
|
37
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
task :test => :check_dependencies
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "rstats #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.4
|
data/lib/rstats.rb
CHANGED
@@ -10,14 +10,14 @@ end
|
|
10
10
|
|
11
11
|
class Array
|
12
12
|
|
13
|
-
if ! self.methods.include?("sum")
|
14
|
-
def
|
13
|
+
# if ! self.methods.include?("sum")
|
14
|
+
def rsum
|
15
15
|
inject(0){ |a, x| a + x }
|
16
16
|
end
|
17
|
-
end
|
17
|
+
# end
|
18
18
|
|
19
19
|
def mean
|
20
|
-
|
20
|
+
rsum.to_f/size
|
21
21
|
end
|
22
22
|
|
23
23
|
def median
|
@@ -34,7 +34,7 @@ class Array
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def variance
|
37
|
-
squares_of_deviations.
|
37
|
+
squares_of_deviations.rsum.to_f/(size - 1)
|
38
38
|
end
|
39
39
|
|
40
40
|
def standard_deviation
|
@@ -62,7 +62,7 @@ class Array
|
|
62
62
|
each do |val|
|
63
63
|
cubed_deviations << ((val-mean)/standard_deviation)**3
|
64
64
|
end
|
65
|
-
(size.to_f/(size.to_f-1)/(size.to_f-2)*cubed_deviations.
|
65
|
+
(size.to_f/(size.to_f-1)/(size.to_f-2)*cubed_deviations.rsum.to_f)
|
66
66
|
end
|
67
67
|
|
68
68
|
end
|
data/test/helper.rb
ADDED
data/test/test_rstats.rb
CHANGED
@@ -1,41 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require 'helper'
|
2
2
|
|
3
3
|
class TestRstats < Test::Unit::TestCase
|
4
|
-
|
5
|
-
|
6
|
-
@sample = [1, 3, 4, 6, 9, 19]
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_truth
|
10
|
-
assert true
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_sum
|
14
|
-
assert_equal @sample.sum, 42
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_mean
|
18
|
-
assert_equal @sample.mean, 7
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_variance
|
22
|
-
assert_equal @sample.variance, 42
|
4
|
+
should "probably rename this file and start testing for real" do
|
5
|
+
flunk "hey buddy, you should probably rename this file and start testing for real"
|
23
6
|
end
|
24
|
-
|
25
|
-
def test_standard_deviation
|
26
|
-
assert_equal @sample.standard_deviation, 6.48074069840786
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_deviations
|
30
|
-
assert_equal @sample.deviations, [-6.0, -4.0, -3.0, -1.0, 2.0, 12.0]
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_squares_of_deviations
|
34
|
-
assert_equal @sample.squares_of_deviations, [36.0, 16.0, 9.0, 1.0, 4.0, 144.0]
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_skewness
|
38
|
-
assert_equal @sample.skewness.round_to(4), 1.5739
|
39
|
-
end
|
40
|
-
|
41
7
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rstats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jimmy Baker
|
@@ -9,61 +9,45 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-10-22 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: thoughtbot-shoulda
|
17
17
|
type: :development
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version:
|
23
|
+
version: "0"
|
24
24
|
version:
|
25
|
-
description:
|
26
|
-
email:
|
27
|
-
- jimmyebaker@gmail.com
|
25
|
+
description: Adds statistical helper methods like mean, median, mode, skewness, etc. to ruby's array class.
|
26
|
+
email: jimmybaker@me.com
|
28
27
|
executables: []
|
29
28
|
|
30
29
|
extensions: []
|
31
30
|
|
32
31
|
extra_rdoc_files:
|
33
|
-
-
|
34
|
-
-
|
35
|
-
- Manifest.txt
|
36
|
-
- PostInstall.txt
|
37
|
-
- README.txt
|
32
|
+
- LICENSE
|
33
|
+
- README.rdoc
|
38
34
|
files:
|
39
|
-
-
|
40
|
-
-
|
41
|
-
-
|
42
|
-
-
|
43
|
-
- README.txt
|
35
|
+
- .document
|
36
|
+
- .gitignore
|
37
|
+
- LICENSE
|
38
|
+
- README.rdoc
|
44
39
|
- Rakefile
|
45
|
-
-
|
46
|
-
- config/requirements.rb
|
40
|
+
- VERSION
|
47
41
|
- lib/rstats.rb
|
48
|
-
-
|
49
|
-
- script/console
|
50
|
-
- script/destroy
|
51
|
-
- script/generate
|
52
|
-
- script/txt2html
|
53
|
-
- setup.rb
|
54
|
-
- tasks/deployment.rake
|
55
|
-
- tasks/environment.rake
|
56
|
-
- tasks/website.rake
|
57
|
-
- test/test_helper.rb
|
42
|
+
- test/helper.rb
|
58
43
|
- test/test_rstats.rb
|
59
44
|
has_rdoc: true
|
60
|
-
homepage: http://rstats
|
61
|
-
|
62
|
-
For more information on rstats, see http://rstats.rubyforge.org
|
45
|
+
homepage: http://github.com/jumzies/rstats
|
46
|
+
licenses: []
|
63
47
|
|
48
|
+
post_install_message:
|
64
49
|
rdoc_options:
|
65
|
-
- --
|
66
|
-
- README.txt
|
50
|
+
- --charset=UTF-8
|
67
51
|
require_paths:
|
68
52
|
- lib
|
69
53
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -80,11 +64,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
64
|
version:
|
81
65
|
requirements: []
|
82
66
|
|
83
|
-
rubyforge_project:
|
84
|
-
rubygems_version: 1.
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 1.3.5
|
85
69
|
signing_key:
|
86
|
-
specification_version:
|
87
|
-
summary:
|
70
|
+
specification_version: 3
|
71
|
+
summary: Adds statistical helper methods like mean, median, mode, skewness, etc. to ruby's array class.
|
88
72
|
test_files:
|
89
|
-
- test/
|
73
|
+
- test/helper.rb
|
90
74
|
- test/test_rstats.rb
|
data/History.txt
DELETED
data/Manifest.txt
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
History.txt
|
2
|
-
License.txt
|
3
|
-
Manifest.txt
|
4
|
-
PostInstall.txt
|
5
|
-
README.txt
|
6
|
-
Rakefile
|
7
|
-
config/hoe.rb
|
8
|
-
config/requirements.rb
|
9
|
-
lib/rstats.rb
|
10
|
-
lib/rstats/version.rb
|
11
|
-
script/console
|
12
|
-
script/destroy
|
13
|
-
script/generate
|
14
|
-
script/txt2html
|
15
|
-
setup.rb
|
16
|
-
tasks/deployment.rake
|
17
|
-
tasks/environment.rake
|
18
|
-
tasks/website.rake
|
19
|
-
test/test_helper.rb
|
20
|
-
test/test_rstats.rb
|
data/PostInstall.txt
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
For more information on rstats, see http://rstats.rubyforge.org
|
data/README.txt
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
= rstats
|
2
|
-
|
3
|
-
http://rstats.rubyforge.org
|
4
|
-
|
5
|
-
== DESCRIPTION:
|
6
|
-
|
7
|
-
A statistical extension to Ruby bases classes (Array and Numeric).
|
8
|
-
|
9
|
-
== FEATURES/PROBLEMS:
|
10
|
-
|
11
|
-
Adds the following methods to the Array class:
|
12
|
-
- mean
|
13
|
-
- median
|
14
|
-
- mode
|
15
|
-
- variance
|
16
|
-
- standard_deviation
|
17
|
-
- skewness
|
18
|
-
|
19
|
-
== SYNOPSIS:
|
20
|
-
|
21
|
-
>> require 'stats'
|
22
|
-
=> true
|
23
|
-
>> sample = [1, 3, 4, 6, 9, 19]
|
24
|
-
=> [1, 3, 4, 6, 9, 19]
|
25
|
-
>> sample.mean
|
26
|
-
=> 7.0
|
27
|
-
>> sample.median
|
28
|
-
=> 5.0
|
29
|
-
>> sample.mode
|
30
|
-
=> [6, 1, 19, 3, 9, 4]
|
31
|
-
>> sample.variance
|
32
|
-
=> 42.0
|
33
|
-
>> sample.standard_deviation
|
34
|
-
=> 6.48074069840786
|
35
|
-
>> sample.skewness
|
36
|
-
=> 1.57389416961334
|
37
|
-
|
38
|
-
== REQUIREMENTS:
|
39
|
-
|
40
|
-
Ruby 1.8.6, RubyGems
|
41
|
-
|
42
|
-
== INSTALL:
|
43
|
-
|
44
|
-
sudo gem install rstats
|
45
|
-
|
46
|
-
== LICENSE:
|
47
|
-
|
48
|
-
(The MIT License)
|
49
|
-
|
50
|
-
Copyright (c) 2008 FIXME full name
|
51
|
-
|
52
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
53
|
-
a copy of this software and associated documentation files (the
|
54
|
-
'Software'), to deal in the Software without restriction, including
|
55
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
56
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
57
|
-
permit persons to whom the Software is furnished to do so, subject to
|
58
|
-
the following conditions:
|
59
|
-
|
60
|
-
The above copyright notice and this permission notice shall be
|
61
|
-
included in all copies or substantial portions of the Software.
|
62
|
-
|
63
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
64
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
65
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
66
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
67
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
68
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
69
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/config/hoe.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'rstats/version'
|
2
|
-
|
3
|
-
AUTHOR = 'Jimmy Baker' # can also be an array of Authors
|
4
|
-
EMAIL = "jimmyebaker@gmail.com"
|
5
|
-
DESCRIPTION = "Statistical extension for Array and Numeric classes."
|
6
|
-
GEM_NAME = 'rstats' # what ppl will type to install your gem
|
7
|
-
RUBYFORGE_PROJECT = 'rstats' # The unix name for your project
|
8
|
-
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
9
|
-
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
10
|
-
EXTRA_DEPENDENCIES = [
|
11
|
-
# ['activesupport', '>= 1.3.1']
|
12
|
-
] # An array of rubygem dependencies [name, version]
|
13
|
-
|
14
|
-
@config_file = "~/.rubyforge/user-config.yml"
|
15
|
-
@config = nil
|
16
|
-
RUBYFORGE_USERNAME = "unknown"
|
17
|
-
def rubyforge_username
|
18
|
-
unless @config
|
19
|
-
begin
|
20
|
-
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
21
|
-
rescue
|
22
|
-
puts <<-EOS
|
23
|
-
ERROR: No rubyforge config file found: #{@config_file}
|
24
|
-
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
25
|
-
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
26
|
-
EOS
|
27
|
-
exit
|
28
|
-
end
|
29
|
-
end
|
30
|
-
RUBYFORGE_USERNAME.replace @config["username"]
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
REV = nil
|
35
|
-
# UNCOMMENT IF REQUIRED:
|
36
|
-
# REV = YAML.load(`svn info`)['Revision']
|
37
|
-
VERS = Rstats::VERSION::STRING + (REV ? ".#{REV}" : "")
|
38
|
-
RDOC_OPTS = ['--quiet', '--title', 'rstats documentation',
|
39
|
-
"--opname", "index.html",
|
40
|
-
"--line-numbers",
|
41
|
-
"--main", "README",
|
42
|
-
"--inline-source"]
|
43
|
-
|
44
|
-
class Hoe
|
45
|
-
def extra_deps
|
46
|
-
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
47
|
-
@extra_deps
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
# Generate all the Rake tasks
|
52
|
-
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
53
|
-
$hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
54
|
-
p.developer(AUTHOR, EMAIL)
|
55
|
-
p.description = DESCRIPTION
|
56
|
-
p.summary = DESCRIPTION
|
57
|
-
p.url = HOMEPATH
|
58
|
-
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
59
|
-
p.test_globs = ["test/**/test_*.rb"]
|
60
|
-
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
61
|
-
|
62
|
-
# == Optional
|
63
|
-
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
64
|
-
#p.extra_deps = EXTRA_DEPENDENCIES
|
65
|
-
|
66
|
-
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
67
|
-
end
|
68
|
-
|
69
|
-
CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
70
|
-
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
71
|
-
$hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
72
|
-
$hoe.rsync_args = '-av --delete --ignore-errors'
|
73
|
-
$hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
|