1 | function [err, aff_err, stable] = compare_affine(M,INC,r,ERR,pts,n,starts, iter)
|
---|
2 | % run shum's method, and mine on the same matrix, and compare with ground truth.
|
---|
3 | % Gaussian error is added to the matrix, with sigma as given.
|
---|
4 | global Mexternal INCexternal
|
---|
5 |
|
---|
6 | num_random_starts = starts;
|
---|
7 | num_data = num_random_starts+2+2;
|
---|
8 | % Each column of the results shows a different method; although the first
|
---|
9 | % num_random_starts columns are all the same iterative method with different
|
---|
10 | % random starting points. Overall, they're organized as:
|
---|
11 | % random starts + my method + my method & iterative, + ground truth + g.t. & it.
|
---|
12 |
|
---|
13 | [M, INC, ERR, pts] = rem_inc_els_pts(M, INC, ERR, pts, r);
|
---|
14 |
|
---|
15 | occpercent = 1 - sum(sum(INC))/size(M,1)/size(M,2);
|
---|
16 |
|
---|
17 | Merr = M + ERR;
|
---|
18 | Mexternal = Merr;
|
---|
19 | INCexternal = INC;
|
---|
20 | INCsize = min(size(INC));
|
---|
21 | if INCsize < r
|
---|
22 | err = repeat(-2,num_data);
|
---|
23 | aff_err = repeat(-2,num_data);
|
---|
24 | else
|
---|
25 | shum_err = [];
|
---|
26 | shum_aff_err = [];
|
---|
27 | for i=1:num_random_starts
|
---|
28 | [s_err, s_mat] = shum(Merr,INC,r,0,100);
|
---|
29 | if s_err ~= -2
|
---|
30 | s_aff_err = affine_error(s_mat, pts, r);
|
---|
31 | else
|
---|
32 | s_aff_err = -2;
|
---|
33 | end
|
---|
34 | shum_aff_err = [shum_aff_err,s_aff_err];
|
---|
35 | shum_err = [shum_err, s_err];
|
---|
36 | end
|
---|
37 | [rankr_err, rankr_res, stable] = rankr(Merr,INC,r,n, iter);
|
---|
38 | if rankr_err ~= -2
|
---|
39 | rankr_aff_err = affine_error(rankr_res, pts, r);
|
---|
40 | else
|
---|
41 | rankr_aff_err = -2;
|
---|
42 | end
|
---|
43 |
|
---|
44 | if rankr_err == -2
|
---|
45 | rankr_shum_err = -2;
|
---|
46 | rankr_shum_aff_err = -2;
|
---|
47 | else
|
---|
48 | [rankr_shum_err, rankr_shum_res] = shum(Merr,INC,r,rankr_res,100);
|
---|
49 | if rankr_shum_err ~= -2
|
---|
50 | rankr_shum_aff_err = affine_error(rankr_shum_res, pts, r);
|
---|
51 | else
|
---|
52 | rankr_shum_aff_err = -2;
|
---|
53 | end
|
---|
54 | end
|
---|
55 |
|
---|
56 | ground_truth_aff_err = affine_error(M,pts,r);
|
---|
57 | ground_truth_err = sum(sum((M.*INC - Merr.*INC).^2));
|
---|
58 | [gt_shum_err, gt_shum_res] = shum(Merr,INC,r,M,100);
|
---|
59 |
|
---|
60 | if gt_shum_err ~= -2
|
---|
61 | gt_shum_aff_err = affine_error(gt_shum_res, pts, r);
|
---|
62 | else
|
---|
63 | gt_shum_aff_err = -2;
|
---|
64 | end
|
---|
65 | err=[shum_err,rankr_err,rankr_shum_err,ground_truth_err,gt_shum_err];
|
---|
66 | aff_err=[shum_aff_err,rankr_aff_err,rankr_shum_aff_err,ground_truth_aff_err,gt_shum_aff_err];
|
---|
67 | end
|
---|