0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 function [E, sigma_0, R] = sugr_estimation_ml_E_Matrix_from_point_pairs(l, xa, T, maxiter)
0023
0024 global print_option_estimation
0025 global min_redundancy
0026
0027
0028 U = 5;
0029 Nlr = 4;
0030 Gc = 1;
0031
0032 lh = l.h;
0033 lCrr = l.Crr;
0034 Nc = size(lh, 1);
0035
0036 G = Nc * Gc;
0037 R = G - U;
0038 if R < 0
0039 return
0040 end;
0041
0042 estl = lh;
0043 w_f = ones(Nc, 1);
0044
0045 if isstruct(xa)
0046 estx = xa.bR;
0047 else
0048 estx = xa;
0049 end
0050
0051 s = 0;
0052 residuals = zeros(Nc, 1);
0053
0054
0055 for nu = 1:maxiter
0056 if print_option_estimation > 0
0057 sprintf('nu = %2', nu);
0058 end
0059 Cr = zeros(Nc, Nlr, Nlr);
0060 v_r = zeros(Nc, Nlr);
0061 A = zeros(Nc, Gc, U);
0062 B = zeros(Nc, Gc, Nlr);
0063 W = zeros(Nc, Gc, Gc);
0064 cg = zeros(Nc, Gc);
0065
0066 N_matrix = zeros(U);
0067 h_vector = zeros(U, 1);
0068
0069
0070 for n = 1:Nc
0071 estl_n = estl(n, :)';
0072 l_n = lh(n, :)';
0073 Crr_n = squeeze(lCrr(n, :, :));
0074
0075 [lr_n, Cr_n, cg_n, atr_n, btr_n] = sugr_ghm_cg_E_matrix_from_point_pairs(l_n, estl_n, estx, Crr_n);
0076
0077 A(n, :, :) = atr_n;
0078 B(n, :, :) = btr_n;
0079 Cr(n, :, :) = Cr_n;
0080 v_r(n, :) = - lr_n';
0081 cg(n, :) = cg_n';
0082
0083
0084 bCovb_n = btr_n * Cr_n * btr_n';
0085 W(n, :, :) = inv(bCovb_n) * w_f(n);
0086 aW = atr_n' * squeeze(W(n,:,:));
0087
0088 N_matrix = N_matrix + aW * atr_n;
0089 h_vector = h_vector + aW * cg_n;
0090
0091 end
0092
0093 if print_option_estimation > 0
0094 N_matrix = N_matrix
0095 l_lambda = log(eigs(N_matrix))
0096 h_vector
0097 end
0098
0099 det(N_matrix);
0100
0101 Cxrxr = inv(N_matrix);
0102 estx_r = Cxrxr * h_vector;
0103
0104 if print_option_estimation > 0
0105 disp(['Result of estimation in iteration: ', num2str(nu)]);
0106 estimated_x = estx_r'
0107 end
0108
0109 max(abs(estx_r) ./ sqrt(diag(Cxrxr)));
0110 if max(abs(estx_r) ./ sqrt(diag(Cxrxr))) < T
0111 s = 2;
0112 end
0113
0114
0115 Omega = 0;
0116
0117 check = zeros(Gc, 1);
0118 for n = 1:Nc
0119
0120 Clrlr = squeeze(Cr(n, :, :));
0121
0122
0123 delta_l_r = Clrlr * squeeze(B(n, :, :)) * squeeze(W(n, :, :)) * ...
0124 (cg(n, :)'-squeeze(A(n,:,:))' * estx_r) - v_r(n, :)';
0125 ver_r = v_r(n, :)' + delta_l_r;
0126
0127
0128 if w_f(n) > 0
0129 vvp_r = ver_r' * inv(Clrlr) * ver_r;
0130 Omega = Omega + vvp_r;
0131 residuals(n) = vvp_r;
0132
0133
0134
0135
0136
0137
0138
0139
0140 end
0141
0142
0143
0144
0145 estl(n, 1:3) = sugr_ghm_update_vector(estl(n, 1:3)',delta_l_r(1:2))';
0146 estl(n, 4:6) = sugr_ghm_update_vector(estl(n, 4:6)',delta_l_r(3:4))';
0147
0148 end
0149 sigma_0 = 1;
0150 if R > min_redundancy
0151 sigma_0 = sqrt(Omega / R);
0152 end
0153 if print_option_estimation > 0
0154 R
0155 sigma_0
0156
0157 end
0158
0159
0160 estx = sugr_ghm_update_E_Matrix(estx, estx_r);
0161
0162
0163 for n = 1:Nc
0164 E = calc_S(estx(:, 1)) * estx(:, 2:4)';
0165 check(n) = estl(n, 1:3) * E * estl(n, 4:6)';
0166 end
0167
0168
0169 if s == 2
0170 break
0171 end
0172
0173 end
0174
0175
0176
0177
0178 if R > min_redundancy
0179 sigma_0 = sqrt(Omega / R);
0180 else
0181 sigma_0 = 1;
0182 end
0183
0184
0185
0186
0187
0188
0189
0190
0191 E = sugr_E_Matrix(estx(:, 1), estx(:, 2:4), Cxrxr);
0192
0193
0194
0195
0196