statsample 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -0
- data/LICENSE.txt +87 -0
- data/Manifest.txt +3 -1
- data/README.txt +7 -4
- data/bin/statsample +1 -1
- data/demo/benchmark.rb +23 -1
- data/lib/statsample/bivariate.rb +9 -1
- data/lib/statsample/crosstab.rb +5 -1
- data/lib/statsample/dominanceanalysis/bootstrap.rb +3 -2
- data/lib/statsample/dominanceanalysis.rb +1 -1
- data/lib/statsample/regression/multiple/gslengine.rb +117 -0
- data/lib/statsample/regression/multiple/rubyengine.rb +1 -8
- data/lib/statsample/regression/multiple.rb +11 -1
- data/lib/statsample/regression.rb +1 -0
- data/lib/statsample/vector.rb +8 -1
- data/lib/statsample.rb +22 -14
- data/setup.rb +1585 -0
- data/test/test_anova.rb +2 -2
- data/test/test_regression.rb +29 -2
- data/test/test_statistics.rb +9 -0
- data/test/test_vector.rb +4 -0
- metadata +6 -3
- data/Rakefile +0 -22
data/test/test_anova.rb
CHANGED
@@ -10,10 +10,10 @@ class StatsampleAnovaTestCase < Test::Unit::TestCase
|
|
10
10
|
super
|
11
11
|
end
|
12
12
|
def test_basic
|
13
|
-
|
13
|
+
assert_in_delta(72.933, @anova.sst,0.001)
|
14
14
|
assert_in_delta(14.8,@anova.sswg,0.001)
|
15
15
|
assert_in_delta(58.133,@anova.ssbg,0.001)
|
16
|
-
|
16
|
+
assert_in_delta(@anova.sst,@anova.sswg+@anova.ssbg,0.00001)
|
17
17
|
assert_equal(14,@anova.df_total)
|
18
18
|
assert_equal(12,@anova.df_wg)
|
19
19
|
assert_equal(2,@anova.df_bg)
|
data/test/test_regression.rb
CHANGED
@@ -27,6 +27,33 @@ class StatsampleRegressionTestCase < Test::Unit::TestCase
|
|
27
27
|
assert_in_delta(3.035,lr.f,0.001)
|
28
28
|
|
29
29
|
end
|
30
|
+
|
31
|
+
|
32
|
+
def test_multiple_regression_gsl
|
33
|
+
if HAS_GSL
|
34
|
+
@a=[1,3,2,4,3,5,4,6,5,7].to_vector(:scale)
|
35
|
+
@b=[3,3,4,4,5,5,6,6,4,4].to_vector(:scale)
|
36
|
+
@c=[11,22,30,40,50,65,78,79,99,100].to_vector(:scale)
|
37
|
+
@y=[3,4,5,6,7,8,9,10,20,30].to_vector(:scale)
|
38
|
+
ds={'a'=>@a,'b'=>@b,'c'=>@c,'y'=>@y}.to_dataset
|
39
|
+
lr=Statsample::Regression::Multiple::GslEngine.new(ds,'y')
|
40
|
+
model_test(lr)
|
41
|
+
predicted=[1.7857, 6.0989, 3.2433, 7.2908, 4.9667, 10.3428, 8.8158, 10.4717, 23.6639, 25.3198]
|
42
|
+
c_predicted=lr.predicted
|
43
|
+
predicted.each_index{|i|
|
44
|
+
assert_in_delta(predicted[i],c_predicted[i],0.001)
|
45
|
+
}
|
46
|
+
residuals=[1.2142, -2.0989, 1.7566, -1.29085, 2.033, -2.3428, 0.18414, -0.47177, -3.66395, 4.6801]
|
47
|
+
c_residuals=lr.residuals
|
48
|
+
residuals.each_index{|i|
|
49
|
+
assert_in_delta(residuals[i],c_residuals[i],0.001)
|
50
|
+
}
|
51
|
+
else
|
52
|
+
puts "Regression::Multiple::AlglibEngine not tested (no Alglib)"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
|
30
57
|
def test_multiple_regression_alglib
|
31
58
|
if HAS_ALGIB
|
32
59
|
@a=[1,3,2,4,3,5,4,6,5,7].to_vector(:scale)
|
@@ -59,7 +86,7 @@ class StatsampleRegressionTestCase < Test::Unit::TestCase
|
|
59
86
|
s_coeffs={'a'=>0.151,'b'=>-0.547,'c'=>0.997}
|
60
87
|
cs_coeefs=lr.standarized_coeffs
|
61
88
|
s_coeffs.each_key{|k|
|
62
|
-
assert_in_delta(s_coeffs[k],cs_coeefs[k],0.001)
|
89
|
+
assert_in_delta(s_coeffs[k], cs_coeefs[k],0.001)
|
63
90
|
}
|
64
91
|
assert_in_delta(639.6,lr.sst,0.001)
|
65
92
|
assert_in_delta(583.76,lr.ssr,0.001)
|
@@ -86,7 +113,7 @@ class StatsampleRegressionTestCase < Test::Unit::TestCase
|
|
86
113
|
assert_in_delta(4.559, lr.constant_se,0.001)
|
87
114
|
assert_in_delta(2.419, lr.constant_t,0.001)
|
88
115
|
end
|
89
|
-
def
|
116
|
+
def test_regression_rubyengine
|
90
117
|
@a=[nil,1,3,2,4,3,5,4,6,5,7].to_vector(:scale)
|
91
118
|
@b=[nil,3,3,4,4,5,5,6,6,4,4].to_vector(:scale)
|
92
119
|
@c=[nil,11,22,30,40,50,65,78,79,99,100].to_vector(:scale)
|
data/test/test_statistics.rb
CHANGED
@@ -127,6 +127,15 @@ class StatsampleStatisicsTestCase < Test::Unit::TestCase
|
|
127
127
|
|
128
128
|
end
|
129
129
|
end
|
130
|
+
def test_ml
|
131
|
+
if(true)
|
132
|
+
real=[1,1,1,1].to_vector(:scale)
|
133
|
+
|
134
|
+
pred=[0.0001,0.0001,0.0001,0.0001].to_vector(:scale)
|
135
|
+
# puts Statsample::Bivariate.maximum_likehood_dichotomic(pred,real)
|
136
|
+
|
137
|
+
end
|
138
|
+
end
|
130
139
|
def test_simple_linear_regression
|
131
140
|
a=[1,2,3,4,5,6].to_vector(:scale)
|
132
141
|
b=[6,2,4,10,12,8].to_vector(:scale)
|
data/test/test_vector.rb
CHANGED
@@ -11,6 +11,10 @@ class StatsampleVectorTestCase < Test::Unit::TestCase
|
|
11
11
|
def test_enumerable
|
12
12
|
val=@c.collect {|v| v}
|
13
13
|
assert_equal(val,[5,5,5,5,5,6,6,7,8,9,10,1,2,3,4,nil,-99,-99])
|
14
|
+
end
|
15
|
+
def test_product
|
16
|
+
a=[1,2,3,4,5].to_vector(:scale)
|
17
|
+
assert_equal(120,a.product)
|
14
18
|
end
|
15
19
|
def test_missing_values
|
16
20
|
@c.missing_values=[10]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statsample
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claudio Bustos
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-04 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -51,13 +51,14 @@ extensions: []
|
|
51
51
|
|
52
52
|
extra_rdoc_files:
|
53
53
|
- History.txt
|
54
|
+
- LICENSE.txt
|
54
55
|
- Manifest.txt
|
55
56
|
- README.txt
|
56
57
|
files:
|
57
58
|
- History.txt
|
59
|
+
- LICENSE.txt
|
58
60
|
- Manifest.txt
|
59
61
|
- README.txt
|
60
|
-
- Rakefile
|
61
62
|
- bin/statsample
|
62
63
|
- demo/benchmark.rb
|
63
64
|
- demo/chi-square.rb
|
@@ -95,6 +96,7 @@ files:
|
|
95
96
|
- lib/statsample/regression.rb
|
96
97
|
- lib/statsample/regression/multiple.rb
|
97
98
|
- lib/statsample/regression/multiple/alglibengine.rb
|
99
|
+
- lib/statsample/regression/multiple/gslengine.rb
|
98
100
|
- lib/statsample/regression/multiple/rubyengine.rb
|
99
101
|
- lib/statsample/regression/simple.rb
|
100
102
|
- lib/statsample/reliability.rb
|
@@ -102,6 +104,7 @@ files:
|
|
102
104
|
- lib/statsample/srs.rb
|
103
105
|
- lib/statsample/test.rb
|
104
106
|
- lib/statsample/vector.rb
|
107
|
+
- setup.rb
|
105
108
|
- test/_test_chart.rb
|
106
109
|
- test/test_anova.rb
|
107
110
|
- test/test_codification.rb
|
data/Rakefile
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
require 'rubygems'
|
5
|
-
require 'hoe'
|
6
|
-
require './lib/statsample'
|
7
|
-
|
8
|
-
if File.exists? './local_rakefile.rb'
|
9
|
-
require './local_rakefile'
|
10
|
-
end
|
11
|
-
|
12
|
-
Hoe.spec('statsample') do |p|
|
13
|
-
p.version=Statsample::VERSION
|
14
|
-
p.rubyforge_name = "ruby-statsample"
|
15
|
-
p.developer('Claudio Bustos', 'clbustos@gmail.com')
|
16
|
-
p.extra_deps << ["spreadsheet","=0.6.4"] << "svg-graph"
|
17
|
-
p.clean_globs << "test/images/*"
|
18
|
-
# p.rdoc_pattern = /^(lib|bin|ext\/distributions)|txt$/
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
# vim: syntax=Ruby
|