chao92 1.0.0 → 1.1.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: a5a9b73405c74abb6de423ca788b1d0ef5279842
4
- data.tar.gz: 1f63a237bfaa760a325f06176047b3800cd14a28
3
+ metadata.gz: 58a6ee103eef46f27541936fee91371e0a00a133
4
+ data.tar.gz: cbfc9bb14b170186828b52d76d8e4eebe90ebfdc
5
5
  SHA512:
6
- metadata.gz: 73bb5c9186d5bd0d307b6953a0b5149dd5a2fb22ee5cc778441876c34a526e9e105acbc2cd1cf5437fbe5cf142c76f39763487d7de33e7dc9cffe9a072f5725e
7
- data.tar.gz: bdfb147517579c653bed584d6437766b9d8fb26361f06d1688fa6d6d70c2f47709ed935d723c6cf9ccb3ada9cdf5709efde5fcc44109cde9eade56594404d2bc
6
+ metadata.gz: eef07e036dc8c3f29f93cf57262659c76e13469220635018f61c7adb81474bcad991c3de927420f9efb3fb0c33015c8c6cc9b756d7b57d34caf3931802a6898c
7
+ data.tar.gz: 1c9b66036df8a8cffae4585bda17af8fab9587c6791737f6f00759e468bce84580ef6acba8a1f5ed82123ae9c844889ce829d91daf898129d290c64772ec14ec
data/1.0.0 ADDED
@@ -0,0 +1,3 @@
1
+ Successfully installed chao92-0.0.2
2
+ Parsing documentation for chao92-0.0.2
3
+ Done installing documentation for chao92 after 0 seconds
data/= ADDED
@@ -0,0 +1,4 @@
1
+ Successfully installed chao92-0.0.2
2
+ Parsing documentation for chao92-0.0.2
3
+ Done installing documentation for chao92 after 0 seconds
4
+ 1 gem installed
@@ -0,0 +1,39 @@
1
+ module Chao92
2
+
3
+ class Predictor
4
+
5
+ def initialize
6
+ @samples = []
7
+ @observed = {}
8
+ @ff = {}
9
+ end
10
+
11
+ def self.run(samples, next_number)
12
+ Predictor.new.predicting(samples, next_number)
13
+ end
14
+
15
+ def predicting(samples, next_number)
16
+ @samples += samples
17
+ update()
18
+ predict(next_number)
19
+ end
20
+
21
+ private
22
+ def update
23
+ @observed = @samples.to_hash
24
+ @ff = @observed.to_inverse
25
+ end
26
+
27
+ def predict(next_number)
28
+ @w = @ff[1] ** 2 / (2.0 * @ff[2])
29
+ @turing_estimator = if @ff[1]
30
+ 1 - @ff[1].to_f / @samples.size
31
+ else
32
+ 1
33
+ end
34
+ @S2 = @w * (1 - (1 - (1 - @turing_estimator) / @w ) ** next_number )
35
+ end
36
+
37
+ end
38
+
39
+ end
@@ -1,3 +1,3 @@
1
1
  module Chao92
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/chao92.rb CHANGED
@@ -2,6 +2,7 @@ require 'support/core_ext'
2
2
 
3
3
  require "chao92/version"
4
4
  require "chao92/estimator"
5
+ require "chao92/predictor"
5
6
 
6
7
  module Chao92
7
8
  end
@@ -15,4 +15,4 @@ class TestEstimator < Minitest::Test
15
15
  assert_equal @estimator.sampling(@samples), Chao92::Estimator.run(@samples)
16
16
  end
17
17
 
18
- end
18
+ end
@@ -0,0 +1,17 @@
1
+ require 'test_helper'
2
+
3
+ class TestPredictor < Minitest::Test
4
+
5
+ def setup
6
+ @samples = [1, 1, 3, 5, 3, 3, 2, 1, 2, 3]
7
+ end
8
+
9
+ def test_predictor_run
10
+ assert_equal Chao92::Predictor.run(@samples, 10).class, Float
11
+ end
12
+
13
+ def test_predictor_more
14
+ assert Chao92::Predictor.run(@samples, 5) < Chao92::Predictor.run(@samples, 20)
15
+ end
16
+
17
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chao92
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eval Air
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-05 00:00:00.000000000 Z
11
+ date: 2015-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -60,6 +60,8 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - ".gitignore"
63
+ - 1.0.0
64
+ - '='
63
65
  - Gemfile
64
66
  - LICENSE.txt
65
67
  - README.md
@@ -67,9 +69,11 @@ files:
67
69
  - chao92.gemspec
68
70
  - lib/chao92.rb
69
71
  - lib/chao92/estimator.rb
72
+ - lib/chao92/predictor.rb
70
73
  - lib/chao92/version.rb
71
74
  - lib/support/core_ext.rb
72
75
  - test/estimator_test.rb
76
+ - test/predictor_test.rb
73
77
  - test/test_helper.rb
74
78
  homepage: ''
75
79
  licenses:
@@ -97,4 +101,5 @@ specification_version: 4
97
101
  summary: An estimator to estimate species richness based on Cho92 estimator
98
102
  test_files:
99
103
  - test/estimator_test.rb
104
+ - test/predictor_test.rb
100
105
  - test/test_helper.rb