distribution 0.7.3 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +4 -6
- data/.yardopts +5 -0
- data/History.txt +3 -0
- data/README.md +87 -44
- data/benchmark/binomial_coefficient.rb +19 -23
- data/benchmark/binomial_coefficient/experiment.rb +33 -36
- data/benchmark/factorial_hash.rb +7 -8
- data/benchmark/factorial_method.rb +4 -6
- data/benchmark/odd.rb +6 -7
- data/benchmark/power.rb +11 -11
- data/bin/distribution +26 -26
- data/distribution.gemspec +3 -4
- data/lib/distribution.rb +55 -96
- data/lib/distribution/beta/gsl.rb +10 -5
- data/lib/distribution/beta/ruby.rb +3 -1
- data/lib/distribution/binomial/ruby.rb +5 -2
- data/lib/distribution/bivariatenormal.rb +4 -5
- data/lib/distribution/bivariatenormal/gsl.rb +2 -2
- data/lib/distribution/bivariatenormal/java.rb +1 -1
- data/lib/distribution/bivariatenormal/ruby.rb +245 -254
- data/lib/distribution/chisquare.rb +8 -10
- data/lib/distribution/chisquare/gsl.rb +24 -19
- data/lib/distribution/chisquare/java.rb +1 -1
- data/lib/distribution/chisquare/ruby.rb +25 -25
- data/lib/distribution/chisquare/statistics2.rb +16 -13
- data/lib/distribution/distributable.rb +40 -0
- data/lib/distribution/exponential.rb +4 -5
- data/lib/distribution/exponential/gsl.rb +13 -9
- data/lib/distribution/exponential/ruby.rb +14 -9
- data/lib/distribution/f.rb +1 -1
- data/lib/distribution/f/gsl.rb +26 -22
- data/lib/distribution/f/java.rb +1 -1
- data/lib/distribution/f/ruby.rb +16 -19
- data/lib/distribution/f/statistics2.rb +22 -19
- data/lib/distribution/gamma.rb +5 -7
- data/lib/distribution/gamma/gsl.rb +13 -9
- data/lib/distribution/gamma/java.rb +1 -1
- data/lib/distribution/gamma/ruby.rb +5 -11
- data/lib/distribution/hypergeometric.rb +5 -8
- data/lib/distribution/hypergeometric/gsl.rb +4 -5
- data/lib/distribution/hypergeometric/java.rb +1 -1
- data/lib/distribution/hypergeometric/ruby.rb +34 -35
- data/lib/distribution/logistic.rb +5 -8
- data/lib/distribution/logistic/ruby.rb +13 -8
- data/lib/distribution/lognormal.rb +5 -7
- data/lib/distribution/lognormal/gsl.rb +8 -6
- data/lib/distribution/lognormal/ruby.rb +5 -9
- data/lib/distribution/math_extension.rb +6 -15
- data/lib/distribution/math_extension/chebyshev_series.rb +281 -272
- data/lib/distribution/math_extension/erfc.rb +26 -29
- data/lib/distribution/math_extension/exponential_integral.rb +17 -17
- data/lib/distribution/math_extension/gammastar.rb +19 -20
- data/lib/distribution/math_extension/gsl_utilities.rb +12 -12
- data/lib/distribution/math_extension/incomplete_beta.rb +52 -61
- data/lib/distribution/math_extension/incomplete_gamma.rb +166 -168
- data/lib/distribution/math_extension/log_utilities.rb +20 -22
- data/lib/distribution/normal.rb +11 -13
- data/lib/distribution/normal/gsl.rb +13 -10
- data/lib/distribution/normal/java.rb +14 -13
- data/lib/distribution/normal/ruby.rb +68 -58
- data/lib/distribution/normal/statistics2.rb +5 -2
- data/lib/distribution/normalmultivariate.rb +64 -64
- data/lib/distribution/poisson.rb +11 -13
- data/lib/distribution/poisson/gsl.rb +7 -7
- data/lib/distribution/poisson/java.rb +19 -24
- data/lib/distribution/poisson/ruby.rb +38 -9
- data/lib/distribution/shorthand.rb +17 -0
- data/lib/distribution/t.rb +13 -15
- data/lib/distribution/t/gsl.rb +27 -24
- data/lib/distribution/t/java.rb +1 -1
- data/lib/distribution/t/ruby.rb +99 -100
- data/lib/distribution/t/statistics2.rb +19 -19
- data/lib/distribution/uniform.rb +26 -0
- data/lib/distribution/uniform/gsl.rb +36 -0
- data/lib/distribution/uniform/ruby.rb +91 -0
- data/lib/distribution/version.rb +1 -1
- data/lib/distribution/weibull.rb +6 -7
- data/lib/distribution/weibull/gsl.rb +16 -16
- data/lib/distribution/weibull/ruby.rb +30 -23
- data/spec/beta_spec.rb +45 -47
- data/spec/binomial_spec.rb +77 -85
- data/spec/bivariatenormal_spec.rb +28 -35
- data/spec/chisquare_spec.rb +48 -52
- data/spec/distribution_spec.rb +10 -10
- data/spec/exponential_spec.rb +44 -49
- data/spec/f_spec.rb +4 -4
- data/spec/gamma_spec.rb +50 -53
- data/spec/hypergeometric_spec.rb +63 -69
- data/spec/logistic_spec.rb +32 -37
- data/spec/lognormal_spec.rb +25 -31
- data/spec/math_extension_spec.rb +192 -210
- data/spec/normal_spec.rb +80 -73
- data/spec/poisson_spec.rb +63 -41
- data/spec/shorthand_spec.rb +19 -22
- data/spec/spec_helper.rb +8 -9
- data/spec/t_spec.rb +63 -77
- data/spec/uniform_spec.rb +154 -0
- data/spec/weibull_spec.rb +13 -14
- metadata +17 -8
data/spec/binomial_spec.rb
CHANGED
@@ -1,130 +1,122 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__)+
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper.rb')
|
2
2
|
include ExampleWithGSL
|
3
3
|
describe Distribution::Binomial do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
4
|
+
shared_examples_for 'binomial engine' do
|
5
|
+
it 'should return correct pdf' do
|
6
|
+
if @engine.respond_to? :pdf
|
7
|
+
[10, 100, 1000].each do |n|
|
8
|
+
[1.quo(4), 1.quo(2), 3.quo(4)].each do |pr|
|
9
|
+
[0, 1, n / 2, n - 1].each do |x|
|
10
|
+
exp = Math.binomial_coefficient(n, x) * pr**x * (1 - pr)**(n - x)
|
11
|
+
obs = @engine.pdf(x, n, pr)
|
12
|
+
expect(obs).to be_within(1e-5).of(exp), "For pdf(#{x},#{n},#{pr}) expected #{exp}, obtained #{obs}"
|
13
|
+
end
|
15
14
|
end
|
16
15
|
end
|
16
|
+
else
|
17
|
+
skip("No #{@engine}.pdf")
|
17
18
|
end
|
18
|
-
else
|
19
|
-
skip("No #{@engine}.pdf")
|
20
19
|
end
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
[10,100].each do |n|
|
25
|
-
[0.25,0.5,0.75].each do |pr|
|
26
|
-
[1,n/2,n-1].each do |x|
|
27
|
-
exp=GSL::Cdf.binomial_P(x,pr,n)
|
28
|
-
obs
|
29
|
-
exp.
|
20
|
+
|
21
|
+
it_only_with_gsl 'should return correct cdf for n<=100' do
|
22
|
+
if @engine.respond_to? :pdf
|
23
|
+
[10, 100].each do |n|
|
24
|
+
[0.25, 0.5, 0.75].each do |pr|
|
25
|
+
[1, n / 2, n - 1].each do |x|
|
26
|
+
exp = GSL::Cdf.binomial_P(x, pr, n)
|
27
|
+
obs = @engine.cdf(x, n, pr)
|
28
|
+
expect(exp).to be_within(1e-5).of(obs), "For cdf(#{x},#{n},#{pr}) expected #{exp}, obtained #{obs}"
|
30
29
|
end
|
31
30
|
end
|
32
31
|
end
|
33
32
|
else
|
34
33
|
skip("No #{@engine}.cdf")
|
35
34
|
end
|
35
|
+
end
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "singleton" do
|
38
|
+
describe 'singleton' do
|
43
39
|
before do
|
44
|
-
@engine=Distribution::Binomial
|
40
|
+
@engine = Distribution::Binomial
|
45
41
|
end
|
46
|
-
|
47
|
-
|
42
|
+
|
43
|
+
it_should_behave_like 'binomial engine'
|
44
|
+
|
45
|
+
it { expect(@engine).to respond_to(:exact_pdf) }
|
46
|
+
|
48
47
|
it {
|
49
|
-
pending(
|
50
|
-
@engine.
|
48
|
+
pending('No exact_p_value')
|
49
|
+
expect(@engine).to respond_to(:exact_p_value)
|
51
50
|
}
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
@engine.exact_cdf(k,n,pr).
|
51
|
+
|
52
|
+
it 'exact_cdf should return same values as cdf for n=50' do
|
53
|
+
pr = rand * 0.8 + 0.1
|
54
|
+
n = rand(10) + 10
|
55
|
+
[1, (n / 2).to_i, n - 1].each do |k|
|
56
|
+
expect(@engine.exact_cdf(k, n, pr)).to be_within(1e-10).of(@engine.cdf(k, n, pr))
|
58
57
|
end
|
59
58
|
end
|
60
|
-
|
61
|
-
it
|
62
|
-
@engine.exact_pdf(1,1,1).
|
63
|
-
@engine.exact_pdf(16, 80, 1.quo(2)).
|
59
|
+
|
60
|
+
it 'exact_pdf should not return a Float if not float is used as parameter' do
|
61
|
+
expect(@engine.exact_pdf(1, 1, 1)).to_not be_a(Float)
|
62
|
+
expect(@engine.exact_pdf(16, 80, 1.quo(2))).to_not be_a(Float)
|
64
63
|
end
|
65
|
-
|
66
64
|
end
|
67
|
-
|
65
|
+
|
68
66
|
describe Distribution::Binomial::Ruby_ do
|
69
67
|
before do
|
70
|
-
@engine=Distribution::Binomial::Ruby_
|
68
|
+
@engine = Distribution::Binomial::Ruby_
|
71
69
|
end
|
72
|
-
it_should_behave_like
|
73
|
-
|
74
|
-
it
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
70
|
+
it_should_behave_like 'binomial engine'
|
71
|
+
|
72
|
+
it 'should return correct cdf for n>100' do
|
73
|
+
[500, 1000].each do |n|
|
74
|
+
[0.5, 0.6].each do |pr|
|
75
|
+
[n / 2].each do |x|
|
76
|
+
cdf = @engine.exact_cdf(x, n, pr)
|
77
|
+
p_value = @engine.p_value(cdf, n, pr)
|
78
|
+
msg = "For p_value(#{cdf},#{n},#{pr}) expected #{x}, obtained #{p_value}"
|
79
|
+
|
80
|
+
expect(p_value).to eq(x), msg
|
81
|
+
end
|
81
82
|
end
|
82
83
|
end
|
83
84
|
end
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
it "should return correct p_value for n<=100" do
|
85
|
+
|
86
|
+
it 'should return correct p_value for n<=100' do
|
88
87
|
pending("Can't calculate with precision x using p")
|
89
|
-
|
90
|
-
[
|
91
|
-
[
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
88
|
+
|
89
|
+
[10, 100].each do |n|
|
90
|
+
[0.25, 0.5, 0.75].each do |pr|
|
91
|
+
[n / 2].each do |x|
|
92
|
+
cdf = @engine.cdf(x, n, pr)
|
93
|
+
p_value = @engine.p_value(cdf, n, pr)
|
94
|
+
|
95
|
+
msg = "For p_value(#{cdf},#{n},#{pr}) expected #{x}, obtained #{p_value}"
|
96
|
+
expect(p_value).to eq(x), msg
|
97
|
+
end
|
96
98
|
end
|
97
99
|
end
|
98
100
|
end
|
99
|
-
end
|
100
|
-
|
101
101
|
end
|
102
|
+
|
102
103
|
if Distribution.has_gsl?
|
103
104
|
describe Distribution::Binomial::GSL_ do
|
104
105
|
before do
|
105
|
-
@engine=Distribution::Binomial::GSL_
|
106
|
+
@engine = Distribution::Binomial::GSL_
|
106
107
|
end
|
107
|
-
|
108
|
+
|
109
|
+
it_should_behave_like 'binomial engine'
|
108
110
|
end
|
109
111
|
end
|
110
|
-
|
111
|
-
# describe Distribution::Binomial::Statistics2_ do
|
112
|
-
#
|
113
|
-
# before do
|
114
|
-
# @engine=Distribution::Binomial::Statistics2_
|
115
|
-
# end
|
116
|
-
#it_should_behave_like "binomial engine"
|
117
|
-
# end
|
118
|
-
#end
|
119
|
-
|
112
|
+
|
120
113
|
if Distribution.has_java?
|
121
114
|
describe Distribution::Binomial::Java_ do
|
122
115
|
before do
|
123
|
-
@engine=Distribution::Binomial::Java_
|
116
|
+
@engine = Distribution::Binomial::Java_
|
124
117
|
end
|
125
|
-
|
126
|
-
|
127
|
-
end
|
118
|
+
|
119
|
+
it_should_behave_like 'binomial engine'
|
120
|
+
end
|
128
121
|
end
|
129
|
-
|
130
122
|
end
|
@@ -1,63 +1,56 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__)+
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper.rb')
|
2
2
|
include ExampleWithGSL
|
3
3
|
describe Distribution::BivariateNormal do
|
4
|
-
shared_examples_for
|
5
|
-
it_only_with_gsl
|
4
|
+
shared_examples_for 'all pdf normal capables engines' do
|
5
|
+
it_only_with_gsl 'should return correct pdf' do
|
6
6
|
if @engine.respond_to? :pdf
|
7
|
-
[0.2,0.4,0.6,0.8,0.9, 0.99,0.999,0.999999].each {|rho|
|
8
|
-
@engine.pdf(0,0, rho
|
7
|
+
[0.2, 0.4, 0.6, 0.8, 0.9, 0.99, 0.999, 0.999999].each {|rho|
|
8
|
+
expect(@engine.pdf(0, 0, rho, 1, 1)).to be_within(1e-8).of(GSL::Ran.bivariate_gaussian_pdf(0, 0, 1, 1, rho))
|
9
9
|
}
|
10
10
|
else
|
11
11
|
pending("No #{@engine}.pdf")
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
15
|
-
|
16
|
-
shared_examples_for
|
17
|
-
it
|
15
|
+
|
16
|
+
shared_examples_for 'all cdf normal capables engines' do
|
17
|
+
it 'should return correct cdf' do
|
18
18
|
if @engine.respond_to? :cdf
|
19
|
-
@engine.cdf(2,0.5,0.5).
|
20
|
-
@engine.cdf(2,0.0,0.5).
|
21
|
-
@engine.cdf(1.5,0.5,0.5).
|
22
|
-
v=rand
|
23
|
-
@engine.cdf(10,0,v).
|
19
|
+
expect(@engine.cdf(2, 0.5, 0.5)).to be_within(1e-3).of(0.686)
|
20
|
+
expect(@engine.cdf(2, 0.0, 0.5)).to be_within(1e-3).of(0.498)
|
21
|
+
expect(@engine.cdf(1.5, 0.5, 0.5)).to be_within(1e-3).of(0.671)
|
22
|
+
v = rand
|
23
|
+
expect(@engine.cdf(10, 0, v)).to be_within(1e-3).of(Distribution::Normal.cdf(0))
|
24
24
|
else
|
25
|
-
|
26
|
-
|
25
|
+
pending("No #{@engine}.cdf")
|
26
|
+
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
30
29
|
end
|
31
|
-
describe
|
30
|
+
describe 'singleton' do
|
32
31
|
before do
|
33
|
-
@engine=Distribution::BivariateNormal
|
32
|
+
@engine = Distribution::BivariateNormal
|
34
33
|
end
|
35
|
-
it_should_behave_like
|
36
|
-
it_should_behave_like
|
37
|
-
|
34
|
+
it_should_behave_like 'all pdf normal capables engines'
|
35
|
+
it_should_behave_like 'all cdf normal capables engines'
|
38
36
|
end
|
39
|
-
|
37
|
+
|
40
38
|
describe Distribution::Normal::Ruby_ do
|
41
39
|
before do
|
42
|
-
@engine=Distribution::BivariateNormal::Ruby_
|
40
|
+
@engine = Distribution::BivariateNormal::Ruby_
|
43
41
|
end
|
44
|
-
it_should_behave_like
|
45
|
-
it_should_behave_like
|
46
|
-
it
|
47
|
-
[-3
|
48
|
-
@engine.cdf_hull(x,x,0.5).
|
49
|
-
|
42
|
+
it_should_behave_like 'all pdf normal capables engines'
|
43
|
+
it_should_behave_like 'all cdf normal capables engines'
|
44
|
+
it 'Ganz method should return similar method to Hull one' do
|
45
|
+
[-3, -2, -1, 0, 1, 1.5].each {|x|
|
46
|
+
expect(@engine.cdf_hull(x, x, 0.5)).to be_within(0.001).of(@engine.cdf_genz(x, x, 0.5))
|
50
47
|
}
|
51
48
|
end
|
52
|
-
|
53
49
|
end
|
54
50
|
describe Distribution::Normal::GSL_ do
|
55
51
|
before do
|
56
|
-
@engine=Distribution::BivariateNormal::GSL_
|
52
|
+
@engine = Distribution::BivariateNormal::GSL_
|
57
53
|
end
|
58
|
-
it_should_behave_like
|
59
|
-
|
54
|
+
it_should_behave_like 'all pdf normal capables engines'
|
60
55
|
end
|
61
|
-
|
62
|
-
|
63
56
|
end
|
data/spec/chisquare_spec.rb
CHANGED
@@ -1,90 +1,86 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__)+
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper.rb')
|
2
2
|
include ExampleWithGSL
|
3
3
|
describe Distribution::ChiSquare do
|
4
|
-
|
5
|
-
|
6
|
-
it_only_with_gsl "should return correct pdf" do
|
4
|
+
shared_examples_for 'Chi-square engine(with pdf)' do
|
5
|
+
it_only_with_gsl 'should return correct pdf' do
|
7
6
|
if @engine.respond_to? :pdf
|
8
7
|
1.upto(10) do |k|
|
9
|
-
v=1+rand(5)
|
10
|
-
chi=GSL::Ran.chisq_pdf(v,k)
|
11
|
-
@engine.pdf(v,k).
|
8
|
+
v = 1 + rand(5)
|
9
|
+
chi = GSL::Ran.chisq_pdf(v, k)
|
10
|
+
expect(@engine.pdf(v, k)).to be_within(10e-10).of(chi)
|
12
11
|
end
|
13
12
|
else
|
14
13
|
skip("No #{@engine}.pdf")
|
15
14
|
end
|
16
15
|
end
|
16
|
+
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
@engine.cdf
|
18
|
+
shared_examples_for 'Chi-square engine' do
|
19
|
+
it_only_with_gsl 'should return correct cdf' do
|
20
|
+
if @engine.respond_to? :cdf
|
21
|
+
1.upto(10) do |k|
|
22
|
+
v = 1 + rand(5)
|
23
|
+
chi = GSL::Cdf.chisq_P(v, k)
|
24
|
+
expect(@engine.cdf(v, k)).to be_within(10e-10).of(chi)
|
25
|
+
end
|
26
|
+
else
|
27
|
+
skip("No #{@engine}.cdf")
|
28
28
|
end
|
29
|
-
|
30
|
-
skip("No #{@engine}.cdf")
|
31
|
-
end
|
32
|
-
end
|
29
|
+
end
|
33
30
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
31
|
+
it 'should return correct p_value' do
|
32
|
+
if @engine.respond_to? :p_value
|
33
|
+
1.upto(10) do |k|
|
34
|
+
v = 1 + rand(5)
|
35
|
+
pr = @engine.cdf(v, k)
|
36
|
+
expect(@engine.p_value(pr, k)).to be_within(10e-4).of(v)
|
37
|
+
end
|
38
|
+
else
|
39
|
+
skip("No #{@engine}.p_value")
|
40
|
+
end
|
43
41
|
end
|
44
42
|
end
|
45
|
-
end
|
46
43
|
|
47
|
-
describe
|
44
|
+
describe 'singleton' do
|
48
45
|
before do
|
49
|
-
@engine=Distribution::ChiSquare
|
46
|
+
@engine = Distribution::ChiSquare
|
50
47
|
end
|
51
|
-
it_should_behave_like
|
52
|
-
it_should_behave_like
|
48
|
+
it_should_behave_like 'Chi-square engine'
|
49
|
+
it_should_behave_like 'Chi-square engine(with pdf)'
|
53
50
|
end
|
54
|
-
|
51
|
+
|
55
52
|
describe Distribution::ChiSquare::Ruby_ do
|
56
53
|
before do
|
57
|
-
@engine=Distribution::ChiSquare::Ruby_
|
54
|
+
@engine = Distribution::ChiSquare::Ruby_
|
58
55
|
end
|
59
|
-
it_should_behave_like
|
60
|
-
it_should_behave_like
|
56
|
+
it_should_behave_like 'Chi-square engine'
|
57
|
+
it_should_behave_like 'Chi-square engine(with pdf)'
|
61
58
|
end
|
62
59
|
if Distribution.has_gsl?
|
63
60
|
describe Distribution::ChiSquare::GSL_ do
|
64
61
|
before do
|
65
|
-
@engine=Distribution::ChiSquare::GSL_
|
62
|
+
@engine = Distribution::ChiSquare::GSL_
|
66
63
|
end
|
67
|
-
|
68
|
-
|
64
|
+
it_should_behave_like 'Chi-square engine'
|
65
|
+
it_should_behave_like 'Chi-square engine(with pdf)'
|
69
66
|
end
|
70
|
-
end
|
67
|
+
end
|
71
68
|
if Distribution.has_statistics2?
|
72
69
|
describe Distribution::ChiSquare::Statistics2_ do
|
73
70
|
before do
|
74
|
-
@engine=Distribution::ChiSquare::Statistics2_
|
71
|
+
@engine = Distribution::ChiSquare::Statistics2_
|
75
72
|
end
|
76
|
-
|
77
|
-
end
|
73
|
+
it_should_behave_like 'Chi-square engine'
|
74
|
+
end
|
78
75
|
end
|
79
|
-
|
76
|
+
|
80
77
|
if Distribution.has_java?
|
81
78
|
describe Distribution::ChiSquare::Java_ do
|
82
79
|
before do
|
83
|
-
@engine=Distribution::ChiSquare::Java_
|
80
|
+
@engine = Distribution::ChiSquare::Java_
|
84
81
|
end
|
85
|
-
|
86
|
-
|
87
|
-
end
|
82
|
+
it_should_behave_like 'Chi-square engine'
|
83
|
+
it_should_behave_like 'Chi-square engine(with pdf)'
|
84
|
+
end
|
88
85
|
end
|
89
|
-
|
90
86
|
end
|
data/spec/distribution_spec.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__)+
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper.rb')
|
2
2
|
describe Distribution do
|
3
|
-
it
|
4
|
-
lambda {Distribution.has_gsl?}.should_not raise_exception
|
3
|
+
it 'should respond to has_gsl?' do
|
4
|
+
lambda { Distribution.has_gsl? }.should_not raise_exception
|
5
5
|
if Distribution.has_gsl?
|
6
6
|
expect(defined?(GSL)).to be
|
7
7
|
else
|
8
|
-
defined?(GSL).
|
9
|
-
end
|
8
|
+
expect(defined?(GSL)).to be_nil
|
9
|
+
end
|
10
10
|
end
|
11
|
-
it
|
12
|
-
lambda {Distribution.has_statistics2?}.should_not raise_exception
|
11
|
+
it 'should respond to has_statistics2?' do
|
12
|
+
lambda { Distribution.has_statistics2? }.should_not raise_exception
|
13
13
|
if Distribution.has_statistics2?
|
14
|
-
defined?(Statistics2).
|
14
|
+
expect(defined?(Statistics2)).to be
|
15
15
|
else
|
16
|
-
defined?(Statistics2).
|
17
|
-
end
|
16
|
+
expect(defined?(Statistics2)).to be_nil
|
17
|
+
end
|
18
18
|
end
|
19
19
|
end
|