distribution 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Distribution
2
- VERSION = "0.7.1"
2
+ VERSION = '0.7.2'
3
3
  end
@@ -9,10 +9,10 @@ describe Distribution::Beta do
9
9
  a=rand * x
10
10
  b=1 + rand * 5
11
11
  g=GSL::Ran.beta_pdf(x,a,b)
12
- @engine.pdf(x,a,b).should be_within(1e-10).of(g)
12
+ @engine.pdf(x,a,b).should be_within(1e-09).of(g)
13
13
  end
14
14
  else
15
- pending("No #{@engine}.pdf")
15
+ skip("No #{@engine}.pdf")
16
16
  end
17
17
  end
18
18
 
@@ -32,7 +32,7 @@ describe Distribution::Beta do
32
32
  @engine.cdf(0.999, 1.2, 1.3).should be_within(tol).of(9.99843792833067634e-1)
33
33
  @engine.cdf(1.0, 1.2, 1.3).should be_within(tol).of(1.0)
34
34
  else
35
- pending("No #{@engine}.cdf")
35
+ skip("No #{@engine}.cdf")
36
36
  end
37
37
  end
38
38
  it "should return correct p_value" do
@@ -41,10 +41,10 @@ describe Distribution::Beta do
41
41
  a=rand() * x
42
42
  b=1 + rand() * 5
43
43
  pr=@engine.cdf(x/100.0,a,b)
44
- @engine.p_value(pr,a, b).should be_within(1e-10).of(x/100.0)
44
+ @engine.p_value(pr,a, b).should be_within(1e-09).of(x/100.0)
45
45
  end
46
46
  else
47
- pending("No #{@engine}.p_value")
47
+ skip("No #{@engine}.p_value")
48
48
  end
49
49
  end
50
50
  end
@@ -55,7 +55,7 @@ end
55
55
  end
56
56
  it_should_behave_like "Beta engine"
57
57
  end
58
-
58
+
59
59
  describe Distribution::Beta::Ruby_ do
60
60
  before do
61
61
  @engine=Distribution::Beta::Ruby_
@@ -76,7 +76,7 @@ end
76
76
  @engine=Distribution::Beta::Java_
77
77
  end
78
78
  it_should_behave_like "Beta engine"
79
- end
79
+ end
80
80
  end
81
-
81
+
82
82
  end
@@ -16,7 +16,7 @@ shared_examples_for "binomial engine" do
16
16
  end
17
17
  end
18
18
  else
19
- pending("No #{@engine}.pdf")
19
+ skip("No #{@engine}.pdf")
20
20
  end
21
21
  end
22
22
  it_only_with_gsl "should return correct cdf for n<=100" do
@@ -31,7 +31,7 @@ shared_examples_for "binomial engine" do
31
31
  end
32
32
  end
33
33
  else
34
- pending("No #{@engine}.cdf")
34
+ skip("No #{@engine}.cdf")
35
35
  end
36
36
  end
37
37
 
@@ -44,8 +44,6 @@ end
44
44
  @engine=Distribution::Binomial
45
45
  end
46
46
  it_should_behave_like "binomial engine"
47
-
48
-
49
47
  it {@engine.should respond_to(:exact_pdf) }
50
48
  it {
51
49
  pending("No exact_p_value")
@@ -64,9 +62,6 @@ end
64
62
  @engine.exact_pdf(1,1,1).should_not be_a(Float)
65
63
  @engine.exact_pdf(16, 80, 1.quo(2)).should_not be_a(Float)
66
64
  end
67
-
68
-
69
-
70
65
 
71
66
  end
72
67
 
@@ -76,8 +71,17 @@ end
76
71
  end
77
72
  it_should_behave_like "binomial engine"
78
73
 
79
- it "should return correct cdf for n>100" do
80
- pending("incomplete beta function is slow. Should be replaced for a faster one")
74
+ it "should return correct cdf for n>100" do
75
+ [500,1000].each do |n|
76
+ [0.5,0.6].each do |pr|
77
+ [n/2].each do |x|
78
+ cdf=@engine.exact_cdf(x,n,pr)
79
+ p_value=@engine.p_value(cdf,n,pr)
80
+ p_value.should eq(x), "For p_value(#{cdf},#{n},#{pr}) expected #{x}, obtained #{p_value}"
81
+ end
82
+ end
83
+ end
84
+
81
85
  end
82
86
 
83
87
  it "should return correct p_value for n<=100" do
@@ -11,7 +11,7 @@ shared_examples_for "Chi-square engine(with pdf)" do
11
11
  @engine.pdf(v,k).should be_within(10e-10).of(chi)
12
12
  end
13
13
  else
14
- pending("No #{@engine}.pdf")
14
+ skip("No #{@engine}.pdf")
15
15
  end
16
16
  end
17
17
 
@@ -27,7 +27,7 @@ shared_examples_for "Chi-square engine" do
27
27
  @engine.cdf(v,k).should be_within(10e-10).of(chi)
28
28
  end
29
29
  else
30
- pending("No #{@engine}.cdf")
30
+ skip("No #{@engine}.cdf")
31
31
  end
32
32
  end
33
33
  it "should return correct p_value" do
@@ -38,7 +38,7 @@ shared_examples_for "Chi-square engine" do
38
38
  @engine.p_value(pr,k).should be_within(10e-4).of(v)
39
39
  end
40
40
  else
41
- pending("No #{@engine}.p_value")
41
+ skip("No #{@engine}.p_value")
42
42
  end
43
43
  end
44
44
  end
@@ -3,17 +3,17 @@ describe Distribution do
3
3
  it "should respond to has_gsl?" do
4
4
  lambda {Distribution.has_gsl?}.should_not raise_exception
5
5
  if Distribution.has_gsl?
6
- expect(defined?(GSL)).to be true
6
+ expect(defined?(GSL)).to be
7
7
  else
8
- defined?(GSL).should be_false
8
+ defined?(GSL).should be_nil
9
9
  end
10
10
  end
11
11
  it "should respond to has_statistics2?" do
12
12
  lambda {Distribution.has_statistics2?}.should_not raise_exception
13
13
  if Distribution.has_statistics2?
14
- defined?(Statistics2).should be_true
14
+ defined?(Statistics2).should be
15
15
  else
16
- defined?(Statistics2).should be_false
16
+ defined?(Statistics2).should be_nil
17
17
  end
18
18
  end
19
19
  end
@@ -1,7 +1,7 @@
1
1
  require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
2
2
 
3
3
  describe Distribution::Exponential do
4
-
4
+
5
5
  shared_examples_for "exponential engine" do
6
6
  it "should return correct pdf" do
7
7
  if @engine.respond_to? :pdf
@@ -47,7 +47,7 @@ shared_examples_for "Gamma engine" do
47
47
  @engine.p_value(pr,a,b).should be_within(1e-3).of(x)
48
48
  end
49
49
  else
50
- pending("No #{@engine}.p_value")
50
+ skip("No #{@engine}.p_value")
51
51
  end
52
52
  end
53
53
  end
@@ -2,10 +2,9 @@ require File.expand_path(File.dirname(__FILE__)+"/spec_helper.rb")
2
2
  include ExampleWithGSL
3
3
  describe Distribution::MathExtension do
4
4
  it "binomial coefficient should be correctly calculated" do
5
-
6
5
  n=50
7
6
  n.times do |k|
8
- Math.binomial_coefficient(n,k).should eq(Math.factorial(n).quo(Math.factorial(k)*Math.factorial(n-k)))
7
+ Math.binomial_coefficient(n,k).should eq(Math.factorial(n).quo(Math.factorial(k)*Math.factorial(n-k))),"not correct for k=#{k}"
9
8
  end
10
9
  end
11
10
 
@@ -41,7 +41,7 @@ describe Distribution::Poisson do
41
41
  }
42
42
  }
43
43
  else
44
- pending("No #{@engine}.p_value")
44
+ skip("No #{@engine}.p_value")
45
45
  end
46
46
  end
47
47
  end
@@ -10,13 +10,28 @@ end
10
10
  require 'rspec'
11
11
  require 'distribution'
12
12
 
13
+ RSpec.configure do |config|
14
+ config.expect_with :rspec do |c|
15
+ c.syntax = [:should, :expect]
16
+ end
17
+
18
+ # Use color in STDOUT
19
+ config.color = true
20
+
21
+ # Use color not only in STDOUT but also in pagers and files
22
+ config.tty = true
23
+
24
+ # Use the specified formatter
25
+ config.formatter = :documentation # :progress, :html, :textmate
26
+ end
27
+
13
28
  module ExampleWithGSL
14
29
  def it_only_with_gsl(name,&block)
15
30
  it(name) do
16
31
  if Distribution.has_gsl?
17
32
  instance_eval(&block)
18
33
  else
19
- pending("Requires GSL")
34
+ skip("Requires GSL")
20
35
  end
21
36
  end
22
37
  end
@@ -26,7 +41,7 @@ module ExampleWithGSL
26
41
  if Distribution.has_java?
27
42
  instance_eval(&block)
28
43
  else
29
- pending("Requires Java")
44
+ skip("Requires Java")
30
45
  end
31
46
  end
32
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: distribution
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Bustos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-06 00:00:00.000000000 Z
11
+ date: 2015-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,16 +16,16 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.0
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.0
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rspec
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -38,8 +38,23 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.2'
41
55
  description: Distribution
42
- email: []
56
+ email:
57
+ - clbustos@gmail.com
43
58
  executables:
44
59
  - distribution
45
60
  extensions: []
@@ -50,7 +65,6 @@ files:
50
65
  - Gemfile
51
66
  - History.txt
52
67
  - LICENCE.md
53
- - Manifest.txt
54
68
  - README.md
55
69
  - Rakefile
56
70
  - benchmark/binomial_coefficient.rb
@@ -155,7 +169,7 @@ files:
155
169
  - spec/t_spec.rb
156
170
  - spec/weibull_spec.rb
157
171
  - vendor/java/commons-math-2.2.jar
158
- homepage: http://rubygems.org/gems/foodie
172
+ homepage: https://github.com/sciruby/distribution
159
173
  licenses: []
160
174
  metadata: {}
161
175
  post_install_message:
@@ -171,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
185
  requirements:
172
186
  - - ">="
173
187
  - !ruby/object:Gem::Version
174
- version: 1.3.6
188
+ version: '0'
175
189
  requirements: []
176
190
  rubyforge_project:
177
191
  rubygems_version: 2.2.2
@@ -1,105 +0,0 @@
1
- Gemfile
2
- History.txt
3
- Manifest.txt
4
- README.txt
5
- Rakefile
6
- benchmark/binomial_coefficient.rb
7
- benchmark/binomial_coefficient/binomial_coefficient.ds
8
- benchmark/binomial_coefficient/binomial_coefficient.xls
9
- benchmark/binomial_coefficient/experiment.rb
10
- benchmark/factorial_hash.rb
11
- benchmark/factorial_method.rb
12
- benchmark/odd.rb
13
- benchmark/power.rb
14
- bin/distribution
15
- data/template/distribution.erb
16
- data/template/distribution/gsl.erb
17
- data/template/distribution/ruby.erb
18
- data/template/spec.erb
19
- lib/distribution.rb
20
- lib/distribution/beta.rb
21
- lib/distribution/beta/gsl.rb
22
- lib/distribution/beta/java.rb
23
- lib/distribution/beta/ruby.rb
24
- lib/distribution/binomial.rb
25
- lib/distribution/binomial/gsl.rb
26
- lib/distribution/binomial/java.rb
27
- lib/distribution/binomial/ruby.rb
28
- lib/distribution/bivariatenormal.rb
29
- lib/distribution/bivariatenormal/gsl.rb
30
- lib/distribution/bivariatenormal/java.rb
31
- lib/distribution/bivariatenormal/ruby.rb
32
- lib/distribution/bivariatenormal/statistics2.rb
33
- lib/distribution/chisquare.rb
34
- lib/distribution/chisquare/gsl.rb
35
- lib/distribution/chisquare/java.rb
36
- lib/distribution/chisquare/ruby.rb
37
- lib/distribution/chisquare/statistics2.rb
38
- lib/distribution/exponential.rb
39
- lib/distribution/exponential/gsl.rb
40
- lib/distribution/exponential/ruby.rb
41
- lib/distribution/f.rb
42
- lib/distribution/f/gsl.rb
43
- lib/distribution/f/java.rb
44
- lib/distribution/f/ruby.rb
45
- lib/distribution/f/statistics2.rb
46
- lib/distribution/gamma.rb
47
- lib/distribution/gamma/gsl.rb
48
- lib/distribution/gamma/java.rb
49
- lib/distribution/gamma/ruby.rb
50
- lib/distribution/hypergeometric.rb
51
- lib/distribution/hypergeometric/gsl.rb
52
- lib/distribution/hypergeometric/java.rb
53
- lib/distribution/hypergeometric/ruby.rb
54
- lib/distribution/logistic.rb
55
- lib/distribution/logistic/ruby.rb
56
- lib/distribution/lognormal.rb
57
- lib/distribution/lognormal/gsl.rb
58
- lib/distribution/lognormal/ruby.rb
59
- lib/distribution/math_extension.rb
60
- lib/distribution/math_extension/chebyshev_series.rb
61
- lib/distribution/math_extension/erfc.rb
62
- lib/distribution/math_extension/exponential_integral.rb
63
- lib/distribution/math_extension/gammastar.rb
64
- lib/distribution/math_extension/gsl_utilities.rb
65
- lib/distribution/math_extension/incomplete_beta.rb
66
- lib/distribution/math_extension/incomplete_gamma.rb
67
- lib/distribution/math_extension/log_utilities.rb
68
- lib/distribution/normal.rb
69
- lib/distribution/normal/gsl.rb
70
- lib/distribution/normal/java.rb
71
- lib/distribution/normal/ruby.rb
72
- lib/distribution/normal/statistics2.rb
73
- lib/distribution/normalmultivariate.rb
74
- lib/distribution/poisson.rb
75
- lib/distribution/poisson/gsl.rb
76
- lib/distribution/poisson/java.rb
77
- lib/distribution/poisson/ruby.rb
78
- lib/distribution/t.rb
79
- lib/distribution/t/gsl.rb
80
- lib/distribution/t/java.rb
81
- lib/distribution/t/ruby.rb
82
- lib/distribution/t/statistics2.rb
83
- lib/distribution/weibull.rb
84
- lib/distribution/weibull/gsl.rb
85
- lib/distribution/weibull/ruby.rb
86
- spec/beta_spec.rb
87
- spec/binomial_spec.rb
88
- spec/bivariatenormal_spec.rb
89
- spec/chisquare_spec.rb
90
- spec/distribution_spec.rb
91
- spec/exponential_spec.rb
92
- spec/f_spec.rb
93
- spec/gamma_spec.rb
94
- spec/hypergeometric_spec.rb
95
- spec/logistic_spec.rb
96
- spec/lognormal_spec.rb
97
- spec/math_extension_spec.rb
98
- spec/normal_spec.rb
99
- spec/poisson_spec.rb
100
- spec/shorthand_spec.rb
101
- spec/spec.opts
102
- spec/spec_helper.rb
103
- spec/t_spec.rb
104
- spec/weibull_spec.rb
105
- vendor/java/commons-math-2.2.jar