aboutsummaryrefslogtreecommitdiff
path: root/tests/aux/calculate_omega.m
diff options
context:
space:
mode:
authorGertjan van den Burg <burg@ese.eur.nl>2016-12-05 19:21:59 +0100
committerGertjan van den Burg <burg@ese.eur.nl>2016-12-05 19:21:59 +0100
commit3713989f5ea8747c2afca4d35e5f2da746f25b24 (patch)
tree902398c9d05c122612bcc76fdd7bc82f04800b6f /tests/aux/calculate_omega.m
parentfurther unit tests for kernel module (diff)
downloadgensvm-3713989f5ea8747c2afca4d35e5f2da746f25b24.tar.gz
gensvm-3713989f5ea8747c2afca4d35e5f2da746f25b24.zip
add octave testfiles to git
Diffstat (limited to 'tests/aux/calculate_omega.m')
-rw-r--r--tests/aux/calculate_omega.m37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/aux/calculate_omega.m b/tests/aux/calculate_omega.m
new file mode 100644
index 0000000..972ab35
--- /dev/null
+++ b/tests/aux/calculate_omega.m
@@ -0,0 +1,37 @@
+more off;
+clear;
+
+rand('state', 21353242);
+
+n = 5;
+m = 3;
+K = 3;
+
+p = 1.213;
+
+y = [ 2 1 3 2 3]';
+
+for i=1:numel(y)
+ fprintf('data->y[%i] = %.16f;\n', i-1, y(i));
+end
+
+H = 2*rand(n, m);
+
+for i=1:size(H, 1)
+ for j=1:size(H, 2)
+ fprintf('matrix_set(A, %i, %i, %i, %.16f);\n', size(H, 2), i-1, j-1, H(i, j));
+ end
+end
+
+R = zeros(n, K);
+I = eye(K);
+for i=1:n
+ R(i, :) = I(y(i, :), :);
+end
+R = ~logical(R);
+
+omega = (1/p)*(sum((H.^p).*R,2)).^(1/p - 1);
+
+for i=1:n
+ fprintf('mu_assert(fabs(gensvm_calculate_omega(model, %i) -\n%.16f) < 1e-14,\n"Incorrect omega at %i");\n', i-1, omega(i), i-1);
+end \ No newline at end of file