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