easystats 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/README +19 -0
- data/Rakefile +2 -0
- data/easystats.gemspec +23 -0
- data/lib/easystats/version.rb +3 -0
- data/lib/easystats.rb +34 -0
- metadata +71 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Gem Name: Easystats
|
2
|
+
Gem Author: Matthew Grigajtis (http://www.matthewgrigajtis.com)
|
3
|
+
Description: Provides easy to use statistical function
|
4
|
+
|
5
|
+
Example usage:
|
6
|
+
|
7
|
+
require "rubygems"
|
8
|
+
require "easystats"
|
9
|
+
|
10
|
+
# Create a test array of numbers
|
11
|
+
myNumbers = Array.new
|
12
|
+
myNumbers = [4, 8, 15, 16, 23, 42]
|
13
|
+
|
14
|
+
# Create a new Easystats Object
|
15
|
+
m = Easystats.new
|
16
|
+
|
17
|
+
puts "Average: " + m.mean(myNumbers).to_s
|
18
|
+
puts "Standard Deviation: " + m.standard_deviation(myNumbers).to_s
|
19
|
+
|
data/Rakefile
ADDED
data/easystats.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "easystats/version"
|
4
|
+
require "complex"
|
5
|
+
include Math
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "easystats"
|
9
|
+
s.version = Easystats::VERSION
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.authors = ["Matthew Grigajtis"]
|
12
|
+
s.email = ["matthew@grigajtis.org"]
|
13
|
+
s.homepage = "https://github.com/mgrigajtis/easystats"
|
14
|
+
s.summary = %q{Easy to use statistics functions}
|
15
|
+
s.description = %q{This gem contains statistics functions that are easy to use.}
|
16
|
+
|
17
|
+
s.rubyforge_project = "easystats"
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
|
+
s.require_paths = ["lib"]
|
23
|
+
end
|
data/lib/easystats.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
class Easystats
|
2
|
+
def self
|
3
|
+
|
4
|
+
end
|
5
|
+
|
6
|
+
# take in an array of numbers and calculate the mean (average)
|
7
|
+
def mean(data)
|
8
|
+
sum_of_numbers = 0
|
9
|
+
|
10
|
+
data.each do |num|
|
11
|
+
sum_of_numbers += num
|
12
|
+
end
|
13
|
+
|
14
|
+
sum_of_numbers / data.count
|
15
|
+
end
|
16
|
+
|
17
|
+
# take in an array of numbers and calculate the standard deviation
|
18
|
+
def standard_deviation(data)
|
19
|
+
average = self.mean(data)
|
20
|
+
deviations = Array.new
|
21
|
+
sum_of_deviations = 0
|
22
|
+
|
23
|
+
data.each do |num|
|
24
|
+
deviations.push((num-average)**2)
|
25
|
+
end
|
26
|
+
|
27
|
+
deviations.each do |num|
|
28
|
+
sum_of_deviations += num
|
29
|
+
end
|
30
|
+
|
31
|
+
Math::sqrt(sum_of_deviations / (data.count-1))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: easystats
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Matthew Grigajtis
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-01-12 00:00:00 -05:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: This gem contains statistics functions that are easy to use.
|
22
|
+
email:
|
23
|
+
- matthew@grigajtis.org
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- Gemfile
|
33
|
+
- README
|
34
|
+
- Rakefile
|
35
|
+
- easystats.gemspec
|
36
|
+
- lib/easystats.rb
|
37
|
+
- lib/easystats/version.rb
|
38
|
+
has_rdoc: true
|
39
|
+
homepage: https://github.com/mgrigajtis/easystats
|
40
|
+
licenses: []
|
41
|
+
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
segments:
|
53
|
+
- 0
|
54
|
+
version: "0"
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project: easystats
|
66
|
+
rubygems_version: 1.3.7
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: Easy to use statistics functions
|
70
|
+
test_files: []
|
71
|
+
|