summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Maunz <andreas@maunz.de>2011-11-08 17:01:32 +0100
committerAndreas Maunz <andreas@maunz.de>2011-11-08 17:01:32 +0100
commit16a994e54ec81018c46e09004c9135af104bd569 (patch)
tree23f3d08c6e12af4fa349b5f630de32b979855a06
parent8578acc48fe5ba47cc99d33b02dbc9eafb68310d (diff)
Adjusted for population
-rw-r--r--transform.rb58
1 files changed, 29 insertions, 29 deletions
diff --git a/transform.rb b/transform.rb
index a00f87d..7642cf0 100644
--- a/transform.rb
+++ b/transform.rb
@@ -22,34 +22,34 @@ def test_mlr
}
end
-# def test_pca
-#
-# d = GSL::Matrix.alloc([1,1.1,2,1.9,3,3.3], 3, 2)
-# td = GSL::Matrix.alloc([-1.3421074161875, -0.127000127000191, 1.46910754318769],3,1)
-# ev = GSL::Matrix.alloc([0.707106781186548, 0.707106781186548], 2, 1)
-# rd = GSL::Matrix.alloc([1.05098674493306, 1.043223563717, 1.91019734898661, 2.0, 3.03881590608033, 3.256776436283], 3, 2)
-#
-# # Lossy
-# 2.times do # repeat to ensure idempotency
-# pca = OpenTox::Algorithm::Transform::PCA.new(d, 0.05)
-# assert_equal pca.data_matrix, d
-# assert_equal pca.data_transformed_matrix, td
-# assert_equal pca.eigenvector_matrix, ev
-# assert_equal pca.restore, rd
-# end
-#
-# td = GSL::Matrix.alloc([-1.3421074161875, 0.0721061461855949, -0.127000127000191, -0.127000127000191, 1.46910754318769, 0.0548939808145955],3,2)
-# ev = GSL::Matrix.alloc([0.707106781186548, -0.707106781186548, 0.707106781186548, 0.707106781186548], 2, 2)
-#
-# # Lossless
-# 2.times do
-# pca = OpenTox::Algorithm::Transform::PCA.new(d, 0.0)
-# assert_equal pca.data_matrix, d
-# assert_equal pca.data_transformed_matrix, td
-# assert_equal pca.eigenvector_matrix, ev
-# assert_equal pca.restore, d
-# end
-#
-# end
+def test_pca
+
+ d = GSL::Matrix.alloc([1,1.1,2,1.9,3,3.3], 3, 2)
+ td = GSL::Matrix.alloc([-1.64373917483226, -0.155542754209564, 1.79928192904182],3,1)
+ ev = GSL::Matrix.alloc([0.707106781186548, 0.707106781186548], 2, 1)
+ rd = GSL::Matrix.alloc([1.05098674493306, 1.043223563717, 1.91019734898661, 2.0, 3.03881590608033, 3.256776436283], 3, 2)
+
+ # Lossy
+ 2.times do # repeat to ensure idempotency
+ pca = OpenTox::Algorithm::Transform::PCA.new(d, 0.05)
+ assert_equal pca.data_matrix, d
+ assert_equal pca.data_transformed_matrix, td
+ assert_equal pca.eigenvector_matrix, ev
+ assert_equal pca.restore, rd
+ end
+
+ td = GSL::Matrix.alloc([-1.64373917483226, 0.0883116327366195, -0.155542754209564, -0.155542754209564, 1.79928192904182, 0.0672311214729441],3,2)
+ ev = GSL::Matrix.alloc([0.707106781186548, -0.707106781186548, 0.707106781186548, 0.707106781186548], 2, 2)
+
+ # Lossless
+ 2.times do
+ pca = OpenTox::Algorithm::Transform::PCA.new(d, 0.0)
+ assert_equal pca.data_matrix, d
+ assert_equal pca.data_transformed_matrix, td
+ assert_equal pca.eigenvector_matrix, ev
+ assert_equal pca.restore, d
+ end
+
+end
end