statsample 0.9.0 → 0.10.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.
Files changed (65) hide show
  1. data.tar.gz.sig +0 -0
  2. data/History.txt +20 -1
  3. data/Manifest.txt +8 -1
  4. data/README.txt +11 -7
  5. data/Rakefile +2 -2
  6. data/data/locale/es/LC_MESSAGES/statsample.mo +0 -0
  7. data/examples/dataset.rb +8 -0
  8. data/examples/multiple_regression.rb +1 -1
  9. data/examples/parallel_analysis.rb +29 -0
  10. data/examples/parallel_analysis_tetrachoric.rb +30 -0
  11. data/examples/vector.rb +6 -0
  12. data/lib/distribution.rb +16 -6
  13. data/lib/distribution/normal.rb +27 -20
  14. data/lib/distribution/normalbivariate.rb +1 -1
  15. data/lib/statsample.rb +19 -2
  16. data/lib/statsample/anova.rb +118 -16
  17. data/lib/statsample/bivariate.rb +27 -13
  18. data/lib/statsample/bivariate/polychoric.rb +18 -5
  19. data/lib/statsample/crosstab.rb +66 -74
  20. data/lib/statsample/dataset.rb +52 -45
  21. data/lib/statsample/dominanceanalysis.rb +2 -5
  22. data/lib/statsample/factor.rb +1 -1
  23. data/lib/statsample/factor/parallelanalysis.rb +122 -0
  24. data/lib/statsample/factor/pca.rb +23 -28
  25. data/lib/statsample/factor/principalaxis.rb +8 -3
  26. data/lib/statsample/matrix.rb +27 -24
  27. data/lib/statsample/mle.rb +11 -11
  28. data/lib/statsample/permutation.rb +2 -1
  29. data/lib/statsample/regression.rb +10 -8
  30. data/lib/statsample/regression/multiple/baseengine.rb +36 -25
  31. data/lib/statsample/regression/multiple/gslengine.rb +14 -0
  32. data/lib/statsample/regression/multiple/matrixengine.rb +4 -32
  33. data/lib/statsample/regression/multiple/rubyengine.rb +2 -6
  34. data/lib/statsample/regression/simple.rb +1 -1
  35. data/lib/statsample/reliability.rb +42 -54
  36. data/lib/statsample/test.rb +10 -6
  37. data/lib/statsample/test/f.rb +16 -26
  38. data/lib/statsample/test/levene.rb +4 -8
  39. data/lib/statsample/test/t.rb +30 -24
  40. data/lib/statsample/test/umannwhitney.rb +13 -6
  41. data/lib/statsample/vector.rb +86 -76
  42. data/po/es/statsample.mo +0 -0
  43. data/po/es/statsample.po +127 -94
  44. data/po/statsample.pot +114 -79
  45. data/test/test_anovaoneway.rb +27 -0
  46. data/test/test_anovawithvectors.rb +97 -0
  47. data/test/test_bivariate.rb +6 -57
  48. data/test/test_bivariate_polychoric.rb +65 -0
  49. data/test/test_crosstab.rb +6 -0
  50. data/test/test_dataset.rb +29 -1
  51. data/test/test_distribution.rb +6 -13
  52. data/test/test_dominance_analysis.rb +1 -1
  53. data/test/test_factor.rb +3 -3
  54. data/test/test_helpers.rb +18 -18
  55. data/test/test_matrix.rb +33 -20
  56. data/test/test_permutation.rb +36 -30
  57. data/test/test_regression.rb +26 -8
  58. data/test/test_reliability.rb +104 -14
  59. data/test/test_test_f.rb +11 -14
  60. data/test/test_test_t.rb +42 -35
  61. data/test/test_umannwhitney.rb +22 -10
  62. data/test/test_vector.rb +204 -102
  63. metadata +57 -81
  64. metadata.gz.sig +0 -0
  65. data/test/test_anova.rb +0 -24
@@ -0,0 +1,27 @@
1
+ require(File.dirname(__FILE__)+'/test_helpers.rb')
2
+
3
+ class StatsampleAnovaOneWayTestCase < MiniTest::Unit::TestCase
4
+ context(Statsample::Anova::OneWay) do
5
+ setup do
6
+ @ss_num=30.08
7
+ @ss_den=87.88
8
+ @df_num=2
9
+ @df_den=21
10
+ @anova=Statsample::Anova::OneWay.new(:ss_num=>@ss_num, :ss_den=>@ss_den, :df_num=>@df_num, :df_den=>@df_den)
11
+ end
12
+ should "Statsample::Anova.oneway respond to #oneway" do
13
+ assert(Statsample::Anova.respond_to? :oneway)
14
+ end
15
+ should "return correct value for ms_num and ms_den" do
16
+ assert_in_delta(15.04, @anova.ms_num, 0.01)
17
+ assert_in_delta(4.18, @anova.ms_den, 0.01)
18
+ end
19
+ should "return correct value for f" do
20
+ assert_in_delta(3.59, @anova.f, 0.01)
21
+ end
22
+ should "respond to summary" do
23
+ assert(@anova.respond_to? :summary)
24
+ assert(@anova.summary.size>0)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,97 @@
1
+ require(File.dirname(__FILE__)+'/test_helpers.rb')
2
+
3
+ class StatsampleAnovaOneWayWithVectorsTestCase < MiniTest::Unit::TestCase
4
+ context(Statsample::Anova::OneWayWithVectors) do
5
+ context("when initializing") do
6
+ setup do
7
+ @v1=10.times.map {rand(100)}.to_scale
8
+ @v2=10.times.map {rand(100)}.to_scale
9
+ @v3=10.times.map {rand(100)}.to_scale
10
+ end
11
+ should "be the same using [] or args*" do
12
+ a1=Statsample::Anova::OneWayWithVectors.new(@v1,@v2,@v3)
13
+ a2=Statsample::Anova::OneWayWithVectors.new([@v1,@v2,@v3])
14
+ assert_equal(a1.f,a2.f)
15
+ end
16
+ should "be the same using module method or object instantiation" do
17
+ a1=Statsample::Anova::OneWayWithVectors.new(@v1,@v2,@v3)
18
+ a2=Statsample::Anova.oneway_with_vectors(@v1,@v2,@v3)
19
+ assert_equal(a1.f,a2.f)
20
+ end
21
+ should "detect optional hash" do
22
+ a1=Statsample::Anova::OneWayWithVectors.new(@v1,@v2,@v3, {:name=>'aaa'})
23
+ assert_equal('aaa', a1.name)
24
+ end
25
+ should "omit incorrect arguments" do
26
+ a1=Statsample::Anova::OneWayWithVectors.new(@v1,@v2,@v3, {:name=>'aaa'})
27
+ a2=Statsample::Anova::OneWayWithVectors.new(@v1,nil,nil,@v2,@v3, {:name=>'aaa'})
28
+ assert_equal(a1.f,a2.f)
29
+ end
30
+ end
31
+ setup do
32
+ @v1=[3,3,2,3,6].to_vector(:scale)
33
+ @v2=[7,6,5,6,7].to_vector(:scale)
34
+ @v3=[9,8,9,7,8].to_vector(:scale)
35
+ @name="Anova testing"
36
+ @anova=Statsample::Anova::OneWayWithVectors.new(@v1,@v2,@v3, :name=>@name)
37
+ end
38
+ should "respond to #summary" do
39
+ assert(@anova.respond_to? :summary)
40
+ end
41
+ should "have correct name of analysis on #summary" do
42
+ assert_match(/#{@name}/, @anova.summary)
43
+ end
44
+ should "returns same levene values as direct Levene creation" do
45
+ assert_equal(@anova.levene.f, Statsample::Test.levene([@v1,@v2,@v3]).f)
46
+ end
47
+ should "have correct value for levene" do
48
+ assert_in_delta(0.604,@anova.levene.f, 0.001)
49
+ assert_in_delta(0.562,@anova.levene.probability, 0.001)
50
+ end
51
+ should "have correct value for sst" do
52
+ assert_in_delta(72.933, @anova.sst,0.001)
53
+ end
54
+ should "have correct value for sswg" do
55
+ assert_in_delta(14.8,@anova.sswg,0.001)
56
+ end
57
+ should "have correct value for ssb" do
58
+ assert_in_delta(58.133,@anova.ssbg,0.001)
59
+ end
60
+ should "sst=sswg+ssbg" do
61
+ assert_in_delta(@anova.sst,@anova.sswg+@anova.ssbg,0.00001)
62
+ end
63
+ should "df total equal to number of n-1" do
64
+ assert_equal(@v1.n+@v2.n+@v3.n-1,@anova.df_total)
65
+ end
66
+ should "df wg equal to number of n-k" do
67
+ assert_equal(@v1.n+@v2.n+@v3.n-3,@anova.df_wg)
68
+ end
69
+ should "df bg equal to number of k-1" do
70
+ assert_equal(2,@anova.df_bg)
71
+ end
72
+ should "f=(ssbg/df_bg)/(sswt/df_wt)" do
73
+ assert_in_delta((@anova.ssbg.quo(@anova.df_bg)).quo( @anova.sswg.quo(@anova.df_wg)), @anova.f, 0.001)
74
+ end
75
+ should "p be correct" do
76
+ assert(@anova.probability<0.01)
77
+ end
78
+ should "be correct using different test values" do
79
+ anova2=Statsample::Anova::OneWayWithVectors.new([@v1,@v1,@v1,@v1,@v2])
80
+ assert_in_delta(3.960, anova2.f,0.001)
81
+ assert_in_delta(0.016, anova2.probability,0.001)
82
+ end
83
+ context "with extra information on summary" do
84
+ setup do
85
+ @anova.summary_descriptives=true
86
+ @anova.summary_levene=true
87
+ @summary=@anova.summary
88
+ end
89
+ should "have section with levene statistics" do
90
+ assert_match(/Levene/, @summary)
91
+ end
92
+ should "have section with descriptives" do
93
+ assert_match(/Min/, @summary)
94
+ end
95
+ end
96
+ end
97
+ end
@@ -8,8 +8,8 @@ class StatsampleBivariateTestCase < MiniTest::Unit::TestCase
8
8
  end
9
9
  def test_covariance
10
10
  if Statsample.has_gsl?
11
- v1=1000.times.collect {|a| rand()}.to_scale
12
- v2=1000.times.collect {|a| rand()}.to_scale
11
+ v1=20.times.collect {|a| rand()}.to_scale
12
+ v2=20.times.collect {|a| rand()}.to_scale
13
13
  assert_in_delta(Statsample::Bivariate.covariance(v1,v2), Statsample::Bivariate.covariance_slow(v1,v2), 0.001)
14
14
  else
15
15
  skip "Bivariate::covariance not tested (needs GSL)"
@@ -19,8 +19,8 @@ class StatsampleBivariateTestCase < MiniTest::Unit::TestCase
19
19
 
20
20
  def test_gsl_pearson
21
21
  if Statsample.has_gsl?
22
- v1=100.times.collect {|a| rand()}.to_scale
23
- v2=100.times.collect {|a| rand()}.to_scale
22
+ v1=20.times.collect {|a| rand()}.to_scale
23
+ v2=20.times.collect {|a| rand()}.to_scale
24
24
 
25
25
  assert_in_delta(GSL::Stats::correlation(v1.gsl, v2.gsl), Statsample::Bivariate.pearson_slow(v1,v2), 1e-10)
26
26
  else
@@ -51,13 +51,8 @@ class StatsampleBivariateTestCase < MiniTest::Unit::TestCase
51
51
  end
52
52
  end
53
53
  end
54
- def test_polychoric_summary
55
- matrix=Matrix[[150+rand(2),150+rand(2)],[150+rand(2),150+rand(2)],[200,300]]
56
- poly = Statsample::Bivariate::Polychoric.new(matrix)
57
- assert(poly.summary.size>0)
58
- end
59
54
  def test_poly_vs_tetra
60
- 5.times {
55
+ 2.times {
61
56
  # Should be the same results as Tetrachoric for 2x2 matrix
62
57
  matrix=Matrix[[150+rand(10),1000+rand(20)],[1000+rand(20),200+rand(20)]]
63
58
  tetra = Statsample::Bivariate::Tetrachoric.new_with_matrix(matrix)
@@ -72,52 +67,6 @@ class StatsampleBivariateTestCase < MiniTest::Unit::TestCase
72
67
  end
73
68
  }
74
69
  end
75
- def test_polychoric
76
-
77
- matrix=Matrix[[58,52,1],[26,58,3],[8,12,9]]
78
- poly=Statsample::Bivariate::Polychoric.new(matrix)
79
- poly.compute_two_step_mle_drasgow_ruby
80
- assert_in_delta(0.420, poly.r, 0.001)
81
- assert_in_delta(-0.240, poly.threshold_y[0],0.001)
82
- assert_in_delta(-0.027, poly.threshold_x[0],0.001)
83
- assert_in_delta(1.578, poly.threshold_y[1],0.001)
84
- assert_in_delta(1.137, poly.threshold_x[1],0.001)
85
- if Statsample.has_gsl?
86
- poly.method=:polychoric_series
87
- poly.compute
88
-
89
- assert_in_delta(0.556, poly.r, 0.001)
90
- assert_in_delta(-0.240, poly.threshold_y[0],0.001)
91
- assert_in_delta(-0.027, poly.threshold_x[0],0.001)
92
- assert_in_delta(1.578, poly.threshold_y[1],0.001)
93
- assert_in_delta(1.137, poly.threshold_x[1],0.001)
94
-
95
- # Example for Tallis(1962, cited by Drasgow, 2006)
96
-
97
- matrix=Matrix[[58,52,1],[26,58,3],[8,12,9]]
98
- poly=Statsample::Bivariate::Polychoric.new(matrix)
99
- poly.compute_two_step_mle_drasgow_gsl
100
- assert_in_delta(0.420, poly.r, 0.001)
101
- assert_in_delta(-0.240, poly.threshold_y[0],0.001)
102
- assert_in_delta(-0.027, poly.threshold_x[0],0.001)
103
- assert_in_delta(1.578, poly.threshold_y[1],0.001)
104
- assert_in_delta(1.137, poly.threshold_x[1],0.001)
105
-
106
-
107
- poly.method=:joint
108
- poly.compute
109
-
110
-
111
- assert_in_delta(0.4192, poly.r, 0.0001)
112
- assert_in_delta(-0.2421, poly.threshold_y[0],0.0001)
113
- assert_in_delta(-0.0297, poly.threshold_x[0],0.0001)
114
- assert_in_delta(1.5938, poly.threshold_y[1],0.0001)
115
- assert_in_delta(1.1331, poly.threshold_x[1],0.0001)
116
- else
117
- skip "Two-step optimized, polychoric series and Joint method for Polychoric requires GSL"
118
- end
119
- assert(poly.summary)
120
- end
121
70
 
122
71
  def test_tetrachoric
123
72
  a,b,c,d=0,0,0,0
@@ -176,7 +125,7 @@ class StatsampleBivariateTestCase < MiniTest::Unit::TestCase
176
125
  for j in 0...expected.column_size
177
126
  #puts expected[i,j].inspect
178
127
  #puts obt[i,j].inspect
179
- assert_in_delta(expected[i,j], obt[i,j],0.0001,"#{expected[i,j].class}!=#{obt[i,j].class} ")
128
+ assert_in_delta(expected[i,j], obt[i,j],0.0001, "#{expected[i,j].class}!=#{obt[i,j].class} ")
180
129
  end
181
130
  end
182
131
  #assert_equal(expected,obt)
@@ -0,0 +1,65 @@
1
+ require(File.dirname(__FILE__)+'/test_helpers.rb')
2
+
3
+ class StatsampleBivariatePolychoricTestCase < MiniTest::Unit::TestCase
4
+ context Statsample::Bivariate do
5
+ should "responde to polychoric_correlation_matrix" do
6
+ a=([1,1,2,2,2,3,3,3,2,2,3,3,3]*4).to_scale
7
+ b=([1,2,2,2,1,3,2,3,2,2,3,3,2]*4).to_scale
8
+ c=([1,1,1,2,2,2,2,3,2,3,2,2,3]*4).to_scale
9
+ ds={'a'=>a,'b'=>b,'c'=>c}.to_dataset
10
+ assert(Statsample::Bivariate.polychoric_correlation_matrix(ds).is_a? ::Matrix)
11
+ end
12
+ end
13
+ context Statsample::Bivariate::Polychoric do
14
+ setup do
15
+ matrix=Matrix[[58,52,1],[26,58,3],[8,12,9]]
16
+ @poly=Statsample::Bivariate::Polychoric.new(matrix)
17
+ end
18
+ should "have summary.size > 0" do
19
+ assert(@poly.summary.size>0)
20
+ end
21
+ should "compute two step mle with ruby" do
22
+ @poly.compute_two_step_mle_drasgow_ruby
23
+ assert_in_delta(0.420, @poly.r, 0.001)
24
+ assert_in_delta(-0.240, @poly.threshold_y[0],0.001)
25
+ assert_in_delta(-0.027, @poly.threshold_x[0],0.001)
26
+ assert_in_delta(1.578, @poly.threshold_y[1],0.001)
27
+ assert_in_delta(1.137, @poly.threshold_x[1],0.001)
28
+ end
29
+ should "compute two-step with gsl" do
30
+ if Statsample.has_gsl?
31
+ @poly.compute_two_step_mle_drasgow_gsl
32
+ assert_in_delta(0.420, @poly.r, 0.001)
33
+ assert_in_delta(-0.240, @poly.threshold_y[0],0.001)
34
+ assert_in_delta(-0.027, @poly.threshold_x[0],0.001)
35
+ assert_in_delta(1.578, @poly.threshold_y[1],0.001)
36
+ assert_in_delta(1.137, @poly.threshold_x[1],0.001)
37
+ else
38
+ skip "Requires GSL"
39
+ end
40
+ end
41
+ should "compute polychoric series" do
42
+ if Statsample.has_gsl?
43
+ @poly.method=:polychoric_series
44
+ @poly.compute
45
+ assert_in_delta(0.556, @poly.r, 0.001)
46
+ assert_in_delta(-0.240, @poly.threshold_y[0],0.001)
47
+ assert_in_delta(-0.027, @poly.threshold_x[0],0.001)
48
+ assert_in_delta(1.578, @poly.threshold_y[1],0.001)
49
+ assert_in_delta(1.137, @poly.threshold_x[1],0.001)
50
+ end
51
+ end
52
+ should "compute joint" do
53
+ if Statsample.has_gsl?
54
+ @poly.method=:joint
55
+ @poly.compute
56
+ assert_in_delta(0.4192, @poly.r, 0.0001)
57
+ assert_in_delta(-0.2421, @poly.threshold_y[0],0.0001)
58
+ assert_in_delta(-0.0297, @poly.threshold_x[0],0.0001)
59
+ assert_in_delta(1.5938, @poly.threshold_y[1],0.0001)
60
+ assert_in_delta(1.1331, @poly.threshold_x[1],0.0001)
61
+ end
62
+ end
63
+ end
64
+
65
+ end
@@ -41,6 +41,12 @@ class StatsampleCrosstabTestCase < MiniTest::Unit::TestCase
41
41
  assert_equal(%w{man woman},fc.keys.sort)
42
42
  assert_equal(Matrix.rows([[3,4],[3,0],[1,0],[1,1]]),@ct.to_matrix)
43
43
  end
44
+ def test_summary
45
+ @ct.percentage_row=true
46
+ @ct.percentage_column=true
47
+ @ct.percentage_total=true
48
+ assert(@ct.summary.size>0)
49
+ end
44
50
  def test_expected
45
51
  v1=%w{1 1 1 1 1 0 0 0 0 0}.to_vector
46
52
  v2=%w{0 0 0 0 0 1 1 1 1 1}.to_vector
data/test/test_dataset.rb CHANGED
@@ -6,6 +6,9 @@ class StatsampleDatasetTestCase < MiniTest::Unit::TestCase
6
6
  'city'=>Statsample::Vector.new(['New York','London','London','Paris','Tome']),
7
7
  'a1'=>Statsample::Vector.new(['a,b','b,c','a',nil,'a,b,c'])}, ['id','name','age','city','a1'])
8
8
  end
9
+ def test_should_have_summary
10
+ assert(@ds.summary.size>0)
11
+ end
9
12
  def test_basic
10
13
  assert_equal(5,@ds.cases)
11
14
  assert_equal(%w{id name age city a1}, @ds.fields)
@@ -192,7 +195,9 @@ class StatsampleDatasetTestCase < MiniTest::Unit::TestCase
192
195
  assert_equal([1,0,1,nil,1],@ds.col('a1_1').to_a)
193
196
  assert_equal([1,1,0,nil,1],@ds.col('a1_2').to_a)
194
197
  assert_equal([0,1,0,nil,1],@ds.col('a1_3').to_a)
195
- assert_equal({'a1_1'=>'a1:a', 'a1_2'=>'a1:b', 'a1_3'=>'a1:c'},@ds.labels)
198
+ {'a1_1'=>'a1:a', 'a1_2'=>'a1:b', 'a1_3'=>'a1:c'}.each do |k,v|
199
+ assert_equal(v, @ds[k].name)
200
+ end
196
201
  end
197
202
  def test_split_by_separator
198
203
  @ds.add_vectors_by_split("a1","_")
@@ -243,6 +248,29 @@ class StatsampleDatasetTestCase < MiniTest::Unit::TestCase
243
248
  assert_same(ds1['v2'],ds2['v2'])
244
249
 
245
250
 
251
+ end
252
+ def test_clone
253
+ v1=[1,2,3,4].to_vector
254
+ v2=[5,6,7,8].to_vector
255
+ ds1=Statsample::Dataset.new({'v1'=>v1,'v2'=>v2}, %w{v2 v1})
256
+ ds2=ds1.clone
257
+ assert_equal(ds1,ds2)
258
+ assert_not_same(ds1,ds2)
259
+ assert_equal(ds1['v1'],ds2['v1'])
260
+ assert_same(ds1['v1'], ds2['v1'])
261
+ assert_equal(ds1.fields,ds2.fields)
262
+ assert_not_same(ds1.fields,ds2.fields)
263
+
264
+ # partial clone
265
+ ds3=ds1.clone('v1')
266
+ ds_exp=Statsample::Dataset.new({'v1'=>v1},%w{v1})
267
+ assert_equal(ds_exp,ds3)
268
+ assert_not_same(ds_exp,ds3)
269
+ assert_equal(ds3['v1'],ds_exp['v1'])
270
+ assert_same(ds3['v1'],ds_exp['v1'])
271
+ assert_equal(ds3.fields,ds_exp.fields)
272
+ assert_not_same(ds3.fields,ds_exp.fields)
273
+
246
274
  end
247
275
  def test_dup
248
276
  v1=[1,2,3,4].to_vector
@@ -2,17 +2,10 @@ require(File.dirname(__FILE__)+'/test_helpers.rb')
2
2
 
3
3
  require 'distribution'
4
4
 
5
- begin
6
- require 'rbgsl'
7
- NOT_GSL=false
8
- rescue LoadError
9
- NOT_GSL=true
10
- end
11
-
12
5
 
13
6
  class DistributionTestCase < MiniTest::Unit::TestCase
14
7
  def test_chi
15
- if !NOT_GSL
8
+ if Distribution.has_gsl?
16
9
  [2,3,4,5].each{|k|
17
10
  chis=rand()*10
18
11
  area=Distribution::ChiSquare.cdf(chis, k)
@@ -22,7 +15,7 @@ class DistributionTestCase < MiniTest::Unit::TestCase
22
15
  end
23
16
  end
24
17
  def test_t
25
- if !NOT_GSL
18
+ if Distribution.has_gsl?
26
19
  [-2,0.1,0.5,1,2].each{|t|
27
20
  [2,5,10].each{|n|
28
21
  area=Distribution::T.cdf(t,n)
@@ -34,7 +27,7 @@ class DistributionTestCase < MiniTest::Unit::TestCase
34
27
  end
35
28
  end
36
29
  def test_normal
37
- if !NOT_GSL
30
+ if Distribution.has_gsl?
38
31
  [-2,0.1,0.5,1,2].each{|x|
39
32
  area=Distribution::Normal.cdf(x)
40
33
  assert_in_delta(area, GSL::Cdf.ugaussian_P(x),0.0001)
@@ -44,7 +37,7 @@ class DistributionTestCase < MiniTest::Unit::TestCase
44
37
  end
45
38
  end
46
39
  def test_normal_bivariate
47
- if !NOT_GSL
40
+ if Distribution.has_gsl?
48
41
  [0.2,0.4,0.6,0.8,0.9, 0.99,0.999,0.999999].each {|rho|
49
42
  assert_equal(GSL::Ran::bivariate_gaussian_pdf(0, 0, 1,1,rho), Distribution::NormalBivariate.pdf(0,0, rho , 1,1))
50
43
 
@@ -53,7 +46,7 @@ class DistributionTestCase < MiniTest::Unit::TestCase
53
46
 
54
47
  [-3,-2,-1,0,1,1.5].each {|x|
55
48
  assert_in_delta(Distribution::NormalBivariate.cdf_hull(x,x,0.5), Distribution::NormalBivariate.cdf_genz(x,x,0.5), 0.001)
56
- assert_in_delta(Distribution::NormalBivariate.cdf_genz(x,x,0.5), Distribution::NormalBivariate.cdf_jantaravareerat(x,x,0.5), 0.001)
49
+ #assert_in_delta(Distribution::NormalBivariate.cdf_genz(x,x,0.5), Distribution::NormalBivariate.cdf_jantaravareerat(x,x,0.5), 0.001)
57
50
  }
58
51
 
59
52
  assert_in_delta(0.686, Distribution::NormalBivariate.cdf(2,0.5,0.5), 0.001)
@@ -63,7 +56,7 @@ class DistributionTestCase < MiniTest::Unit::TestCase
63
56
  assert_in_delta(Distribution::Normal.cdf(0), Distribution::NormalBivariate.cdf(10,0,0.9), 0.001)
64
57
  end
65
58
  def test_f
66
- if !NOT_GSL
59
+ if Distribution.has_gsl?
67
60
  [0.1,0.5,1,2,10,20,30].each{|f|
68
61
  [2,5,10].each{|n2|
69
62
  [2,5,10].each{|n1|
@@ -1,7 +1,7 @@
1
1
  require(File.dirname(__FILE__)+'/test_helpers.rb')
2
2
 
3
3
  class StatsampleDominanceAnalysisTestCase < MiniTest::Unit::TestCase
4
- def aatest_dominance_univariate
4
+ def test_dominance_univariate
5
5
  # Example from Budescu (1993)
6
6
  m=Matrix[[1, 0.683, 0.154, 0.460, 0.618],[0.683, 1, -0.050, 0.297, 0.461], [0.154, -0.050, 1, 0.006, 0.262],[0.460, 0.297, 0.006, 1, 0.507],[0.618, 0.461, 0.262, 0.507, 1]]
7
7
  m.extend Statsample::CovariateMatrix
data/test/test_factor.rb CHANGED
@@ -84,9 +84,9 @@ class StatsampleFactorTestCase < MiniTest::Unit::TestCase
84
84
  [0.0826106, 0.435975, -0.893379],
85
85
  [0.939901, -0.0965213, -0.309596]].to_gsl
86
86
  varimax=Statsample::Factor::Varimax.new(a)
87
- refute(varimax.rotated.nil?,"Rotated shouldn't be empty")
88
- refute(varimax.component_transformation_matrix.nil?, "Component matrix shouldn't be empty")
89
- refute(varimax.h2.nil?,"H2 shouldn't be empty")
87
+ assert(!varimax.rotated.nil?, "Rotated shouldn't be empty")
88
+ assert(!varimax.component_transformation_matrix.nil?, "Component matrix shouldn't be empty")
89
+ assert(!varimax.h2.nil?,"H2 shouldn't be empty")
90
90
  _test_matrix(expected,varimax.rotated)
91
91
  else
92
92
  skip "Rotation not tested. Requires GSL"
data/test/test_helpers.rb CHANGED
@@ -1,38 +1,38 @@
1
1
  $:.unshift(File.dirname(__FILE__)+'/../lib/')
2
+
2
3
  require 'statsample'
3
4
  require 'minitest/unit'
4
5
  require 'tempfile'
5
6
  require 'tmpdir'
6
7
  require 'shoulda'
8
+
7
9
  module MiniTest
8
10
  class Unit
9
11
  class TestCase
10
12
  include Shoulda::InstanceMethods
11
13
  extend Shoulda::ClassMethods
12
14
  include Shoulda::Assertions
13
-
15
+
14
16
  end
15
17
  end
16
- end
17
18
 
18
- module MiniTest::Assertions
19
-
20
- alias :assert_raise :assert_raises unless method_defined? :assert_raise
21
- alias :assert_not_equal :refute_equal unless method_defined? :assert_not_equal
22
- alias :assert_not_same :refute_same unless method_defined? :assert_not_same
23
- unless method_defined? :assert_nothing_raised
24
- def assert_nothing_raised(msg=nil)
25
- msg||="Nothing should be raised, but raised %s"
26
- begin
27
- yield
28
- not_raised=true
29
- rescue Exception => e
30
- not_raised=false
31
- msg=sprintf(msg,e)
19
+ module Assertions
20
+ alias :assert_raise :assert_raises unless method_defined? :assert_raise
21
+ alias :assert_not_equal :refute_equal unless method_defined? :assert_not_equal
22
+ alias :assert_not_same :refute_same unless method_defined? :assert_not_same
23
+ unless method_defined? :assert_nothing_raised
24
+ def assert_nothing_raised(msg=nil)
25
+ msg||="Nothing should be raised, but raised %s"
26
+ begin
27
+ yield
28
+ not_raised=true
29
+ rescue Exception => e
30
+ not_raised=false
31
+ msg=sprintf(msg,e)
32
+ end
33
+ assert(not_raised,msg)
32
34
  end
33
- assert(not_raised,msg)
34
35
  end
35
36
  end
36
37
  end
37
-
38
38
  MiniTest::Unit.autorun