alglib 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,16 +1,52 @@
1
+ $:.unshift(File.expand_path(File.dirname(__FILE__)+"/../lib"))
2
+ $:.unshift(File.expand_path(File.dirname(__FILE__)+"/../ext"))
3
+
1
4
  require "test/unit"
5
+ begin
6
+ require 'statsample'
7
+ HAS_SS=true
8
+ rescue
9
+ HAS_SS=false
10
+ end
11
+
12
+ if(HAS_GSL.nil?)
13
+ begin
14
+ require 'rbgsl'
15
+ HAS_GSL=true
16
+ rescue
17
+ HAS_GSL=false
18
+ end
19
+ end
20
+
2
21
  require "alglib"
3
22
  require 'matrix'
4
23
  class TestAlglib < Test::Unit::TestCase
5
24
  def test_linear_regression
6
- a=[1,3,2,4,3,5,4,6,5,7]
7
- b=[3,3,4,4,5,5,6,6,4,4]
8
- c=[11,22,30,40,50,65,78,79,99,100]
9
- y=[3,4,5,6,7,8,9,10,20,30]
10
- matrix=Matrix.columns([a,b,c,y])
11
- lr=Alglib::LinearRegression.build_from_matrix(matrix)
12
- assert_in_delta(0.695,lr.coeffs[0],0.001)
13
- assert_in_delta(11.027,lr.constant,0.001)
14
- assert_in_delta(1.785,lr.process([1,3,11]),0.001)
25
+ a=[1,3,2,4,3,5,4,6,5,7]
26
+ b=[3,3,4,4,5,5,6,6,4,4]
27
+ c=[11,22,30,40,50,65,78,79,99,100]
28
+ y=[3,4,5,6,7,8,9,10,20,30]
29
+ matrix=Matrix.columns([a,b,c,y])
30
+ lr=Alglib::LinearRegression.build_from_matrix(matrix)
31
+ assert_in_delta(0.695,lr.coeffs[0],0.001)
32
+ assert_in_delta(11.027,lr.constant,0.001)
33
+ assert_in_delta(1.785,lr.process([1,3,11]),0.001)
34
+ end
35
+ def test_array_to_real1darray
36
+ v=[1,2,3]
37
+ r1d=Alglib.array_to_real1darray(v)
38
+ assert_equal(3,r1d.size)
39
+ assert_equal(1,r1d[0])
40
+ assert_equal(2,r1d[1])
41
+ assert_equal(3,r1d[2])
15
42
  end
43
+ def test_real2darray_to_array
44
+ m=Matrix[[0,3,4],[1,2,5],[3,5,6]]
45
+ v2=m.to_alglib_matrix
46
+ m2=Alglib.real2darray_to_array(v2)
47
+ assert_equal(3,m2.size)
48
+ assert_equal([0,3,4],m2[0])
49
+ assert_equal([1,2,5],m2[1])
50
+ assert_equal([3,5,6],m2[2])
51
+ end
16
52
  end
@@ -0,0 +1,44 @@
1
+ $:.unshift(File.expand_path(File.dirname(__FILE__)+"/../lib"))
2
+ $:.unshift(File.expand_path(File.dirname(__FILE__)+"/../ext"))
3
+
4
+ require "test/unit"
5
+ begin
6
+ require 'statsample'
7
+ HAS_SS=true
8
+ rescue
9
+ HAS_SS=false
10
+ end
11
+
12
+ if(HAS_GSL.nil?)
13
+ begin
14
+ require 'rbgsl'
15
+ HAS_GSL=true
16
+ rescue
17
+ HAS_GSL=false
18
+ end
19
+ end
20
+
21
+ require "alglib"
22
+ require 'matrix'
23
+ class TestAlglibCorrelation < Test::Unit::TestCase
24
+ def test_correlation
25
+ a=[1,2,3,6,7,9,0,10]
26
+ b=[2,5, 7,8,4,8, 0, 5]
27
+
28
+ if(HAS_GSL)
29
+ a_gsl=GSL::Vector.alloc(a)
30
+ b_gsl=GSL::Vector.alloc(b)
31
+ corr_expected=GSL::Stats::correlation(a_gsl, b_gsl)
32
+ corr_alglib=Alglib.pearson_correlation(a,b)
33
+ assert_equal(corr_expected,corr_alglib)
34
+ end
35
+ if(HAS_SS)
36
+ va=a.to_vector(:scale)
37
+ vb=b.to_vector(:scale)
38
+ corr_expected=Statsample::Bivariate::spearman(va, vb)
39
+ corr_alglib=Alglib.spearman_correlation(a,b)
40
+ assert_in_delta(corr_expected,corr_alglib,0.001)
41
+ end
42
+ end
43
+
44
+ end
@@ -0,0 +1,45 @@
1
+ $:.unshift(File.expand_path(File.dirname(__FILE__)+"/../lib"))
2
+ $:.unshift(File.expand_path(File.dirname(__FILE__)+"/../ext"))
3
+
4
+ require "test/unit"
5
+ begin
6
+ require 'statsample'
7
+ HAS_SS=true
8
+ rescue
9
+ HAS_SS=false
10
+ end
11
+
12
+ if(HAS_GSL.nil?)
13
+ begin
14
+ require 'rbgsl'
15
+ HAS_GSL=true
16
+ rescue
17
+ HAS_GSL=false
18
+ end
19
+ end
20
+
21
+ require "alglib"
22
+ require 'matrix'
23
+ class TestAlglibCorrelationTests < Test::Unit::TestCase
24
+ def test_pearson
25
+ a=[2,3,4,5,6,7,8,9 ,10,22,20]
26
+ b=[1,4,3,5,6,8,9,10,10,20,30]
27
+ r=Alglib.pearson_correlation(a,b)
28
+ t= Statsample::Bivariate.t_r(r, a.size)
29
+ out = Alglib.pearson_correlation_significance(r, a.size)
30
+ assert_in_delta(out[:both], Statsample::Bivariate.prop_pearson(t,a.size), 0.0001)
31
+ assert_in_delta(out[:left], Statsample::Bivariate.prop_pearson(t, a.size,:left), 0.0001)
32
+ assert_in_delta(out[:right], Statsample::Bivariate.prop_pearson(t,a.size, :right), 0.0001)
33
+ end
34
+ def test_spearman
35
+ a=[2,3,4,5,6,7,8,9 ,10,22,20]
36
+ b=[1,4,3,5,6,8,9,10,10,20,30]
37
+ r=Alglib.spearman_correlation(a,b)
38
+ t= Statsample::Bivariate.t_r(r, a.size)
39
+ out = Alglib.spearman_correlation_significance(r, a.size)
40
+
41
+ assert_in_delta(out[:both], Statsample::Bivariate.prop_pearson(t,a.size), 0.0001)
42
+ assert_in_delta(out[:left], Statsample::Bivariate.prop_pearson(t, a.size,:left), 0.0001)
43
+ assert_in_delta(out[:right], Statsample::Bivariate.prop_pearson(t,a.size, :right), 0.0001)
44
+ end
45
+ end
@@ -0,0 +1,35 @@
1
+ $:.unshift(File.expand_path(File.dirname(__FILE__)+"/../lib"))
2
+ $:.unshift(File.expand_path(File.dirname(__FILE__)+"/../ext"))
3
+
4
+ require "test/unit"
5
+ begin
6
+ require 'statsample'
7
+ HAS_SS=true
8
+ rescue
9
+ HAS_SS=false
10
+ end
11
+
12
+ if(HAS_GSL.nil?)
13
+ begin
14
+ require 'rbgsl'
15
+ HAS_GSL=true
16
+ rescue
17
+ HAS_GSL=false
18
+ end
19
+ end
20
+
21
+ require "alglib"
22
+ require 'matrix'
23
+ class TestAlglibLinreg < Test::Unit::TestCase
24
+ def test_linear_regression
25
+ a=[1,3,2,4,3,5,4,6,5,7]
26
+ b=[3,3,4,4,5,5,6,6,4,4]
27
+ c=[11,22,30,40,50,65,78,79,99,100]
28
+ y=[3,4,5,6,7,8,9,10,20,30]
29
+ matrix=Matrix.columns([a,b,c,y])
30
+ lr=Alglib::LinearRegression.build_from_matrix(matrix)
31
+ assert_in_delta(0.695,lr.coeffs[0],0.001)
32
+ assert_in_delta(11.027,lr.constant,0.001)
33
+ assert_in_delta(1.785,lr.process([1,3,11]),0.001)
34
+ end
35
+ end
@@ -0,0 +1,43 @@
1
+ $:.unshift(File.expand_path(File.dirname(__FILE__)+"/../lib"))
2
+ $:.unshift(File.expand_path(File.dirname(__FILE__)+"/../ext"))
3
+
4
+ require "test/unit"
5
+ begin
6
+ require 'statsample'
7
+ HAS_SS=true
8
+ rescue
9
+ HAS_SS=false
10
+ end
11
+
12
+ if(HAS_GSL.nil?)
13
+ begin
14
+ require 'rbgsl'
15
+ HAS_GSL=true
16
+ rescue
17
+ HAS_GSL=false
18
+ end
19
+ end
20
+
21
+ require "alglib"
22
+ require 'matrix'
23
+ class TestAlglib < Test::Unit::TestCase
24
+ def test_logit
25
+ a=[1,2,3,4,5,6,7,8,9,10]
26
+ b=[0,0,1,0,0,0,1,1,1,1]
27
+ matrix=Matrix.columns([a,b])
28
+ lr=Alglib::Logit.build_from_matrix(matrix)
29
+ end
30
+ def atest_logit_1
31
+ ds=Statsample::CSV.read(File.dirname(__FILE__)+"/sample_logit.csv")
32
+ ds['female'].recode! {|c|
33
+ c=='female' ? 1: 0
34
+ }
35
+ constant=[1]*(ds.cases)
36
+ matrix=Matrix.columns([ds['female'].data,ds['hon'].data])
37
+ lr=Alglib::Logit.build_from_matrix(matrix)
38
+ lr.unpack
39
+ matrix=Matrix.columns([ds['math'].data, ds['female'].data,ds['read'].data, ds['hon'].data])
40
+ lr=Alglib::Logit.build_from_matrix(matrix)
41
+
42
+ end
43
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alglib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
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-03 00:00:00 -04:00
12
+ date: 2009-08-20 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 2.3.2
23
+ version: 2.3.3
24
24
  version:
25
25
  description: ALGLIB - is a multilingual collection of algorithms designed to solve problems in the field of numeric analysis and data processing. ALGLIB is distributed under a 3-clause BSD license. This license is unrestrictive and allows using the package both in open and proprietary programs and even relicensing the code (if the new license doesn't conflict with the terms of the 3-clause BSD license).
26
26
  email:
@@ -274,9 +274,19 @@ files:
274
274
  - ext/alglib/variancetests.h
275
275
  - ext/alglib/wsr.cpp
276
276
  - ext/alglib/wsr.h
277
+ - ext/ap.i
278
+ - ext/correlation.i
277
279
  - ext/extconf.rb
280
+ - ext/logit.i
278
281
  - lib/alglib.rb
282
+ - lib/alglib/correlation.rb
283
+ - lib/alglib/linearregression.rb
284
+ - lib/alglib/logit.rb
279
285
  - test/test_alglib.rb
286
+ - test/test_correlation.rb
287
+ - test/test_correlationtest.rb
288
+ - test/test_linreg.rb
289
+ - test/test_logit.rb
280
290
  has_rdoc: true
281
291
  homepage: http://rubyforge.org/projects/ruby-statsample/
282
292
  licenses: []
@@ -308,4 +318,8 @@ signing_key:
308
318
  specification_version: 3
309
319
  summary: ALGLIB - is a multilingual collection of algorithms designed to solve problems in the field of numeric analysis and data processing
310
320
  test_files:
321
+ - test/test_correlation.rb
322
+ - test/test_correlationtest.rb
311
323
  - test/test_alglib.rb
324
+ - test/test_logit.rb
325
+ - test/test_linreg.rb