basic-stats 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e3801e30fbbe3d7b3e731e1a5feca120b5915de
4
- data.tar.gz: b738414f640c231200c547ded2eeb7de13804231
3
+ metadata.gz: 954cf4ea4a93f8817eb667bbc3f62e26c6cb55e4
4
+ data.tar.gz: ea1e480076b70cb45b9308b61f20e5e6ee9e6f05
5
5
  SHA512:
6
- metadata.gz: d963ad59b357a9dbee66f352cf5d447a7b1330a6bf7f1f66cfb103d672ee527e3037ee6a4cc348d4217b9e9ad64a5f29b813a15dabd6e330aabd8ff816771da7
7
- data.tar.gz: 1118862cb6811aea2417a3e66c122cf320dc70bfc7e27294f44fa0d316ee5168ca73ee2f771d7ef2e60c8684773db26a8ccb95260e21f64e6c127fad0a6ef0c6
6
+ metadata.gz: 9ef5bba7d45c8d599de018be6146d788e01e418721ddc4b77c618bbd239074a430e6e1e6b8cd2368a0ed1cc18f275e1dd46e4cbd4aad39cba6c43c76a159bbef
7
+ data.tar.gz: 51d0d236cd48d6b36983af55d9e54460842f1a23e441dc8dc80cee86f402ba1f7dace9368bbdcb233a63760ffb58820cd19d07da3ce5413d78123af86465af67
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .coveralls.yml
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
1
  # Basic::Stats
2
+ [![Build Status](https://secure.travis-ci.org/cpetersen/basic-stats.png)](http://travis-ci.org/cpetersen/basic-stats)
3
+ [![Code Climate](https://codeclimate.com/github/cpetersen/basic-stats.png)](https://codeclimate.com/github/cpetersen/basic-stats)
4
+ [![Gem Version](https://badge.fury.io/rb/basic-stats.png)](http://badge.fury.io/rb/basic-stats)
2
5
 
3
6
  Basic statistical functions for Ruby collections, such as mean, standard_deviation, z, and outlier detection
4
7
 
@@ -53,6 +56,8 @@ The Grubb's test does not work well for detecting multiple outliers.
53
56
 
54
57
  1. Fork it
55
58
  2. Create your feature branch (`git checkout -b my-new-feature`)
56
- 3. Commit your changes (`git commit -am 'Add some feature'`)
57
- 4. Push to the branch (`git push origin my-new-feature`)
58
- 5. Create new Pull Request
59
+ 3. Make your changes
60
+ 4. Make sure the specs run (`bundle exec rake spec`)
61
+ 5. Commit your changes (`git commit -am 'Add some feature'`)
62
+ 6. Push to the branch (`git push origin my-new-feature`)
63
+ 7. Create new Pull Request
data/Rakefile CHANGED
@@ -1 +1,8 @@
1
+ #!/usr/bin/env rake
1
2
  require "bundler/gem_tasks"
3
+
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :test => :spec
8
+ task :default => :spec
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "coveralls"
22
23
  spec.add_development_dependency "rake"
23
24
  spec.add_development_dependency "rspec"
24
25
  end
@@ -10,6 +10,12 @@ module Basic
10
10
  self.sum/self.length.to_f
11
11
  end
12
12
 
13
+ def median
14
+ sorted = self.sort
15
+ len = sorted.length
16
+ return (sorted[(len - 1) / 2] + sorted[len / 2]) / 2.0
17
+ end
18
+
13
19
  def sample_variance
14
20
  m = self.mean
15
21
  sum = self.inject(0){|accum, i| accum +(i-m)**2 }
@@ -1,5 +1,5 @@
1
1
  module Basic
2
2
  module Stats
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -1,4 +1,5 @@
1
1
  require "basic/stats"
2
+ require "coveralls"
2
3
 
3
4
  # This file was generated by the `rspec --init` command. Conventionally, all
4
5
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
@@ -17,3 +18,5 @@ RSpec.configure do |config|
17
18
  # --seed 1234
18
19
  config.order = 'random'
19
20
  end
21
+
22
+ Coveralls.wear!
@@ -1,6 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Basic::Stats do
4
+ let(:short_array) { [1,2,3].extend Basic::Stats }
4
5
  let(:array) { [1,2,3,4,5,6,7,8,9,10].extend Basic::Stats }
5
6
  let(:array_with_outlier) { [1,2,3,4,5,6,7,8,9,30].extend Basic::Stats }
6
7
 
@@ -8,6 +9,18 @@ describe Basic::Stats do
8
9
  array.mean.should == 5.5
9
10
  end
10
11
 
12
+ it "should have a mean of 5.5" do
13
+ array.median.should == 5.5
14
+ end
15
+
16
+ it "should have a mean of 5.5" do
17
+ array_with_outlier.median.should == 5.5
18
+ end
19
+
20
+ it "should have a mean of 2" do
21
+ short_array.median.should == 2
22
+ end
23
+
11
24
  it "should have a standard deviation of 3.02765..." do
12
25
  array.standard_deviation.should == 3.0276503540974917
13
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: basic-stats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Petersen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-20 00:00:00.000000000 Z
11
+ date: 2014-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: coveralls
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement