Home > 10-Uncertain-Geometry > Demo-Point-2D > demo_estimate_Point_2D_from_Lines.m

demo_estimate_Point_2D_from_Lines

PURPOSE ^

% demo_estimate_Point_2D_from_Lines

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

% demo_estimate_Point_2D_from_Lines

 see Sect. 10.6.2.1, Figs. 10.24-10.26

 four types of estimation of intersection point (vanishing point)
       ALGe algebraic Euclideanly
       ALGs algebraic spherically
       SSDe geometric Euclideanly
       MLEe ML Euclideanly
       MLEs ML spherically

 comparison of empirical and theoretical covariance matrices
 
 Wolfgang Förstner
 wfoerstn@uni-bonn.de

 last changes: Susanne Wenzel 06/18
 wenzel@igg.uni-bonn.de

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% demo_estimate_Point_2D_from_Lines
0002 %
0003 % see Sect. 10.6.2.1, Figs. 10.24-10.26
0004 %
0005 % four types of estimation of intersection point (vanishing point)
0006 %       ALGe algebraic Euclideanly
0007 %       ALGs algebraic spherically
0008 %       SSDe geometric Euclideanly
0009 %       MLEe ML Euclideanly
0010 %       MLEs ML spherically
0011 %
0012 % comparison of empirical and theoretical covariance matrices
0013 %
0014 % Wolfgang Förstner
0015 % wfoerstn@uni-bonn.de
0016 %
0017 % last changes: Susanne Wenzel 06/18
0018 % wenzel@igg.uni-bonn.de
0019 
0020 addpath(genpath('../../General-Functions'))
0021 
0022 global min_redundancy
0023 global plot_option
0024 global print_option
0025 global print_option_estimation
0026 
0027 close all
0028 % clear all
0029 clearvars
0030 clc
0031 
0032 sugr_INIT
0033 ss = plot_init;
0034 min_redundancy=100000;
0035 
0036 disp('=====================================================================')
0037 disp('   Point estimation (geometric, ALG, ML; Euclideanly, spherically)   ')
0038 disp('                    Figures 10.24 - 10.26                            ')
0039 disp('---------------------------------------------------------------------')
0040 
0041 %% Control parameters
0042 N_samples     = 100;                  % number of cases (for first trial)
0043 %N_samples     = 1000;                  % number of cases
0044 disp(strcat('Number of samples            : ' , num2str(N_samples)));
0045 
0046 % sample sizes
0047 N             = 50;                   % number of lines per case
0048 disp(strcat('Number of lines              : ' , num2str(N)));
0049 
0050 % parameters for line generation
0051 d             = 1.0;                  % size of square [-d,+d]^2 image wrt c=1
0052 resolution    = 1000;                 % number of pixels per d
0053 
0054 
0055 disp(strcat('Size of image                : ' , num2str(resolution)));
0056 
0057 %
0058 lengthq       = 200;                  % average length of line segments
0059 disp(strcat('Average length of lines      : ' , num2str(lengthq)));
0060 sigma         = 1.0;                  % std. dev. of pixels on line
0061 disp(strcat('Std. dev. of pixels on lines : ' , num2str(sigma)));
0062 
0063 % initial seed
0064 init_rand      = 11;                  % random seed
0065 
0066 % type of simulation
0067 sim_type = 0; % close unknown point  -->  Figs. 10.24-10.25
0068 %sim_type = 1; % far unknown point     -->  Fig.  10.26
0069 
0070 % factor for plotting the standard ellipses
0071 factor_p      = 1000;   
0072 
0073 % rigorous variance propagation for observed line segment
0074 %rigorous      = 0;
0075 rigorous      = 1;
0076 
0077 %% initialize random seed
0078 init_rand_seed(init_rand);
0079 
0080 %% Generate lines
0081 
0082 if N_samples >1 
0083     print_option_estimation=0;
0084 end
0085 %
0086 switch sim_type
0087     case 0
0088         x_tilde_e      =[1.3;1.7];
0089     case 1
0090         x_tilde_e     = [0,200]';
0091 end
0092 disp(strcat('True point                   : [',num2str(x_tilde_e(1)),',',num2str(x_tilde_e(2)),']'));
0093 
0094 %
0095 x_tilde       = sugr_Point_2D(x_tilde_e,10^-10*eye(2));   % true point
0096 
0097 % -------------------------------------------------------------------------
0098 % generate true lines
0099 lines = sugr_generate_true_Lines_2D_one_Point(x_tilde.h,d,N,lengthq,resolution);
0100 
0101 % show representatative result
0102 plot_option = 2;                                                           %#ok<NASGU>
0103 print_option = 2;                                                          %#ok<NASGU>
0104 
0105 if sim_type == 0    
0106     
0107     figure('name','estimate intersection points','Color','w','Position',[10,50,0.5*ss(1),0.85*ss(2)])
0108     subplot(3,2,1)
0109     hold on
0110     sugr_perturb_Lines_2D(x_tilde.h,d,lines,resolution,sigma,rigorous);    
0111     title('Original line segments')
0112     
0113     subplot(3,2,2)
0114     hold on
0115     sugr_perturb_Lines_2D(x_tilde.h,d,lines,resolution,sigma,rigorous);
0116     
0117     subplot(3,2,3)
0118     hold on
0119     sugr_perturb_Lines_2D(x_tilde.h,d,lines,resolution,sigma,rigorous);
0120         
0121     subplot(3,2,4)
0122     hold on
0123     sugr_perturb_Lines_2D(x_tilde.h,d,lines,resolution,sigma,rigorous);
0124         
0125     subplot(3,2,5)
0126     hold on
0127     sugr_perturb_Lines_2D(x_tilde.h,d,lines,resolution,sigma,rigorous);
0128     
0129     subplot(3,2,6)
0130     hold on
0131     sugr_perturb_Lines_2D(x_tilde.h,d,lines,resolution,sigma,rigorous);
0132     
0133 end
0134 
0135 % do not plot samples in the following
0136 plot_option  = 0;
0137 print_option = 0;
0138 % -------------------------------------------------------
0139 est_x_samples_aE = zeros(N_samples,2);
0140 sigma_2_aE_D     = zeros(N_samples,1);
0141 sigma_2_aE_O     = zeros(N_samples,1);
0142 
0143 est_x_samples_a = zeros(N_samples,2);
0144 sigma_2_a_D     = zeros(N_samples,1);
0145 sigma_2_a_O     = zeros(N_samples,1);
0146 
0147 est_x_samples_g = zeros(N_samples,2);
0148 sigma_2_g_D     = zeros(N_samples,1);
0149 sigma_2_g_O     = zeros(N_samples,1);
0150 
0151 est_x_samples_g_x = zeros(N_samples,2);
0152 sigma_2_g         = zeros(N_samples,1);
0153 
0154 est_x_samples_ml = zeros(N_samples,2);
0155 sigma_2_ml        = zeros(N_samples,1);
0156 sigma_2_ml_D     = zeros(N_samples,1);
0157 sigma_2_ml_O     = zeros(N_samples,1);
0158 
0159 est_x_samples_mH = zeros(N_samples,2);
0160 sigma_2_mH        = zeros(N_samples,1);
0161 sigma_2_mH_D     = zeros(N_samples,1);
0162 sigma_2_mH_O     = zeros(N_samples,1);
0163 
0164 start = cputime;
0165 for n = 1:N_samples
0166      if N_samples < 100
0167         fprintf(num2str(n)),fprintf(',')
0168         if mod(n,10) == 0
0169             disp(' ')
0170         end
0171     else
0172         if mod(n,10) == 0
0173             fprintf(num2str(n)),fprintf(',')
0174         end
0175         if mod(n,100) == 0
0176             disp(' ')
0177         end
0178     end
0179     % perturb lines
0180     lstruct = sugr_perturb_Lines_2D(x_tilde.h,d,lines,resolution,sigma,rigorous);
0181     
0182     
0183     %% Estimate point algebraically - Euclideanly
0184     [est_p_aE,sigma_0_est_DE,sigma_0_est_OE] = ...
0185         sugr_estimation_algebraic_Point_2D_from_Lines(lstruct,0);
0186     est_x_aE_e = est_p_aE.h(1:2)'/est_p_aE.h(3);
0187     est_x_samples_aE(n,:) = est_x_aE_e;
0188     sigma_2_aE_D(n) = sigma_0_est_DE^2;
0189     sigma_2_aE_O(n) = sigma_0_est_OE^2;    
0190     
0191     if sim_type == 0
0192         plot([-2,-2,2,2,-2],[-2,2,2,-2,-2],'-b')
0193         
0194         subplot(3,2,2)
0195         hold on
0196         plot(x_tilde_e(1)+factor_p*(est_x_aE_e(1)-x_tilde_e(1))/3,...
0197             x_tilde_e(2)+factor_p*(est_x_aE_e(2)-x_tilde_e(2))/3,'.g');
0198     end
0199     
0200     %% Estimate point algebraically - spherically
0201     [est_p_a,sigma_0_est_D,sigma_0_est_O] = ...
0202         sugr_estimation_algebraic_Point_2D_from_Lines(lstruct,1);
0203     est_x_a_e = est_p_a.h(1:2)'/est_p_a.h(3);
0204     est_x_samples_a(n,:) = est_x_a_e;
0205     sigma_2_a_D(n) = sigma_0_est_D^2;
0206     sigma_2_a_O(n) = sigma_0_est_O^2;    
0207     
0208     if sim_type == 0
0209         plot([-2,-2,2,2,-2],[-2,2,2,-2,-2],'-b')        
0210         
0211         subplot(3,2,3)
0212         hold on
0213         plot(x_tilde_e(1)+factor_p*(est_x_a_e(1)-x_tilde_e(1))/3,...
0214             x_tilde_e(2)+factor_p*(est_x_a_e(2)-x_tilde_e(2))/3,'.g');
0215     end
0216     
0217     %% Estimate point geometrically
0218     [est_p_g,sigma_0_g,xe] = sugr_estimation_geometric_Point_2D_from_Lines(lstruct);
0219     est_x_g_e              = est_p_g.h(1:2)'/est_p_g.h(3);
0220     est_x_samples_g(n,:)   = est_x_g_e;
0221     est_x_samples_g_x(n,:) = xe;
0222     sigma_2_g(n)           = sigma_0_g^2;
0223     
0224     if sim_type == 0
0225         plot([-2,-2,2,2,-2],[-2,2,2,-2,-2],'-b')        
0226         
0227         subplot(3,2,4)
0228         hold on
0229         plot(x_tilde_e(1)+factor_p*(est_x_g_e(1)-x_tilde_e(1))/3,...
0230             x_tilde_e(2)+factor_p*(est_x_g_e(2)-x_tilde_e(2))/3,'.g');
0231     end
0232     
0233     %% estimate ML
0234     T = 0.01;
0235     maxiter = 3;
0236     [est_p_ml,sigma_0_ml,~] = sugr_estimation_ml_Point_2D_from_Lines(lstruct,est_p_a.h,T,maxiter);
0237     [est_x_ml_e,Cxx_ml]     = sugr_get_Euclidean_Point_2D(est_p_ml);
0238     est_x_samples_ml(n,:)   = est_x_ml_e;
0239     sigma_2_ml(n)           = sigma_0_ml^2;
0240     
0241     if sim_type == 0
0242         plot([-2,-2,2,2,-2],[-2,2,2,-2,-2],'-b')
0243         
0244         subplot(3,2,5)
0245         hold on
0246         plot(x_tilde_e(1)+factor_p*(est_x_ml_e(1)-x_tilde_e(1))/3,...
0247             x_tilde_e(2)+factor_p*(est_x_ml_e(2)-x_tilde_e(2))/3,'.g');
0248     end
0249     %% estimate ML-Hessian
0250     T = 0.01;
0251     maxiter = 3;
0252     [est_p_mH,sigma_0_mH,R] = sugr_estimation_ml_Point_2D_from_Lines_Hessian(lstruct,est_p_a.h,T,maxiter);
0253     [est_x_mH_e,Cxx_mH]  = sugr_get_Euclidean_Point_2D(est_p_mH);
0254     est_x_samples_mH(n,:) = est_x_mH_e;
0255     sigma_2_mH(n) = sigma_0_mH^2;    
0256     
0257     if sim_type == 0
0258         plot([-2,-2,2,2,-2],[-2,2,2,-2,-2],'-b')        
0259         
0260         subplot(3,2,6)
0261         hold on
0262         plot(x_tilde_e(1)+factor_p*(est_x_mH_e(1)-x_tilde_e(1))/3,...
0263              x_tilde_e(2)+factor_p*(est_x_mH_e(2)-x_tilde_e(2))/3,'.g');        
0264         
0265         plot([-2,-2,2,2,-2],[-2,2,2,-2,-2],'-b')
0266     end
0267 end
0268 disp(['CPU time for ', num2str(N_samples),' samples              : ',num2str(cputime-start)]);
0269 
0270 %% Analyse samples
0271 [x_aE_e,Cxx_aE_e] = sugr_get_Euclidean_Point_2D(est_p_aE);
0272 [x_a_e, Cxx_a_e]  = sugr_get_Euclidean_Point_2D(est_p_a);
0273 [x_g_e, Cxx_g_e]  = sugr_get_Euclidean_Point_2D(est_p_g);
0274 [x_ml_e,Cxx_ml_e] = sugr_get_Euclidean_Point_2D(est_p_ml);
0275 [x_mH_e,Cxx_mH_e] = sugr_get_Euclidean_Point_2D(est_p_mH);
0276 
0277 if N_samples > 2
0278     %% determine empirtical means and covariance matrices
0279     est_x_mean_aE  = mean(est_x_samples_aE);
0280     est_x_cov_aE   = cov(est_x_samples_aE);
0281     est_x_mean_a   = mean(est_x_samples_a);
0282     est_x_cov_a    = cov(est_x_samples_a);
0283     est_x_mean_g   = mean(est_x_samples_g);
0284     est_x_cov_g    = cov(est_x_samples_g);
0285     est_x_mean_ml  = mean(est_x_samples_ml);
0286     est_x_cov_ml   = cov(est_x_samples_ml);
0287     est_x_mean_mH  = mean(est_x_samples_mH);
0288     est_x_cov_mH   = cov(est_x_samples_mH);
0289     
0290     mean_sigma_2_a_OE = mean(sigma_2_aE_O);
0291     mean_sigma_2_a_DE = mean(sigma_2_aE_D);
0292     mean_sigma_2_a_O  = mean(sigma_2_a_O);
0293     mean_sigma_2_a_D  = mean(sigma_2_a_D);
0294     mean_sigma_2_g    = mean(sigma_2_g);
0295     mean_sigma_2_ml_Euclidean   = mean(sigma_2_ml);
0296     mean_sigma_2_ml_spherical   = mean(sigma_2_mH);
0297     
0298     %%
0299     est_p_aE_emp    = sugr_Point_2D(est_x_mean_aE', est_x_cov_aE);
0300     est_p_a_emp     = sugr_Point_2D(est_x_mean_a', est_x_cov_a);
0301     est_p_g_emp     = sugr_Point_2D(est_x_mean_g', est_x_cov_g);
0302     est_p_ml_emp    = sugr_Point_2D(est_x_mean_ml',est_x_cov_ml);
0303     est_p_mH_emp    = sugr_Point_2D(est_x_mean_mH',est_x_cov_mH);    
0304     
0305     if sim_type == 0
0306         subplot(3,2,1)
0307         if sim_type == 0
0308             xlim([-2.2,+2.5])
0309             ylim([-2.2,2.9])
0310         end
0311         
0312         subplot(3,2,2)
0313         
0314         title('ALGe emp (green) - ALGe theor (blue)')
0315         hold on
0316         sugr_plot_Point_2D(est_p_aE_emp,'ok','-g',2,factor_p);
0317         hold on
0318         sugr_plot_Point_2D(est_p_aE,'ok','-b',1,factor_p);
0319         axis equal
0320         if sim_type == 0
0321             xlim([-2.2,+2.5])
0322             ylim([-2.2,2.9])
0323         end
0324         
0325         subplot(3,2,3)
0326         
0327         title('ALGs')
0328         hold on
0329         %sugr_plot_Point_2D(est_p_a_emp,'ok','-g',2,factor_p);
0330         hold on
0331         sugr_plot_Point_2D(est_p_a,'ok','-k',1,factor_p);
0332         axis equal
0333         if sim_type == 0
0334             xlim([-2.2,+2.5])
0335             ylim([-2.2,2.9])
0336         end
0337         
0338         subplot(3,2,4)
0339         title('SSDe')
0340         hold on
0341         %sugr_plot_Point_2D(est_p_g_emp,'ok','-g',2,factor_p);
0342         hold on
0343         %sugr_plot_Point_2D(est_p_g,'ok','-b',1,factor_p);
0344         axis equal
0345         if sim_type == 0
0346             xlim([-2.2,+2.5])
0347             ylim([-2.2,2.9])
0348         end
0349         
0350         subplot(3,2,5)
0351         title('MLEe')
0352         % sugr_plot_Point_2D(est_p_mH_emp,'ok','-g',2,factor_p);
0353         hold on
0354         sugr_plot_Point_2D(est_p_mH,'ok','-k',1,factor_p);
0355         axis equal
0356         if sim_type == 0
0357             xlim([-2.2,+2.5])
0358             ylim([-2.2,2.9])
0359         end        
0360         
0361         subplot(3,2,6)
0362         title('MLEs (green) - ALGs (dashed)')
0363         sugr_plot_Point_2D(est_p_a,'ok','--k',1,factor_p);
0364         hold on
0365         sugr_plot_Point_2D(est_p_ml,'ok','-k',1,factor_p);
0366         axis equal
0367         if sim_type == 0
0368             xlim([-2.2,+2.5])
0369             ylim([-2.2,2.9])
0370         end
0371     end
0372     
0373 % % distance between the covariance matrices
0374 % distance_a_emp= exp(sqrt(sum(log(eigs(inv(Cxx_a_e)*est_x_cov_a)).^2)/2)/2)
0375 % distance_g_emp= exp(sqrt(sum(log(eigs(inv(Cxx_g_e)*est_x_cov_g)).^2)/2)/2)
0376 %
0377 % distance_a_ml = exp(sqrt(sum(log(eigs(inv(Cxx_ml_e)* Cxx_a_e )).^2)/2)/2)
0378 % distance_g_ml = exp(sqrt(sum(log(eigs(inv(Cxx_ml_e)* Cxx_g_e )).^2)/2)/2)
0379 end
0380 
0381 %% final distribution of points
0382 
0383 % algebraic solution
0384 if N_samples > 2
0385 %% show histograms
0386     figure('name','Histogramms','Color','w','Position',[ss(1)/2,0.3*ss(2),0.5*ss(1),0.6*ss(2)])   
0387     N_bin = ceil(sqrt(N_samples));
0388     
0389     subplot(3,2,2)
0390     hist(sigma_2_a_D,N_bin);
0391     title('Variance ALGe')
0392     
0393     subplot(3,2,3)
0394     hist(sigma_2_aE_D,N_bin);
0395     title('Variance ALGs')
0396     
0397     subplot(3,2,4)
0398     hist(sigma_2_g,N_bin);
0399     title('Variance SSDe')
0400     
0401     subplot(3,2,5)
0402     hold on
0403     hist(sigma_2_mH,N_bin);
0404     [~,r] = hist(sigma_2_mH,N_bin);
0405     %r=2*(1:ceil(sqrt(N_samples))-1/2)/N_bin;
0406     range = abs(r(N_bin)-r(1));
0407     plot(r,N_bin*range*fpdf(r,R,10000),'-r','LineWidth',2);
0408     
0409     title('Variance factor MLEe')
0410     
0411     subplot(3,2,6)
0412     hold on
0413     hist(sigma_2_ml,N_bin);
0414     [NN,r] = hist(sigma_2_ml,N_bin);
0415     %r=2*(1:ceil(sqrt(N_samples))-1/2)/N_bin;
0416     range = abs(r(N_bin)-r(1));
0417     plot(r,N_bin*range*fpdf(r,R,10000),'-r','LineWidth',2);
0418     
0419     title('Variance factor MLEs')
0420 
0421     %%  show
0422     figure('name','Distribution of points','Color','w','Position',[100,20,0.6*ss(1),0.82*ss(2)])
0423     plot_option=1;
0424     subplot(3,2,1)
0425     hold on
0426     title('Straight line segments')
0427     sugr_perturb_Lines_2D(x_tilde.h,d,lines,resolution,sigma,rigorous);
0428 
0429     subplot(3,2,2)
0430     hold on
0431     title('ALGe')
0432     for n=1:N_samples
0433         plot(est_x_mean_aE(1)+(est_x_samples_aE(n,1)-est_x_mean_aE(1)),...
0434             est_x_mean_aE(2)+(est_x_samples_aE(n,2)-est_x_mean_aE(2)),'.k');
0435     end
0436     sugr_plot_Point_2D(est_p_aE_emp,'ok','--k',1,3);
0437 
0438     plot(est_x_mean_aE(1),est_x_mean_aE(2),'ow','MarkerSize',12,'LineWidth',7);
0439     plot(est_x_mean_aE(1),est_x_mean_aE(2),'ok','MarkerSize',12,'LineWidth',3);
0440 
0441     plot(x_tilde.h(1)/x_tilde.h(3),x_tilde.h(2)/x_tilde.h(3),'+k','MarkerSize',10,'LineWidth',1);
0442 
0443     xlim_aE=xlim;
0444     ylim_aE=ylim;
0445 
0446     subplot(3,2,3)
0447     hold on
0448     title('ALGs')
0449     for n = 1:N_samples
0450         plot(est_x_mean_a(1)+(est_x_samples_a(n,1)-est_x_mean_a(1)),...
0451             est_x_mean_a(2)+(est_x_samples_a(n,2)-est_x_mean_a(2)),'.k');
0452     end
0453     sugr_plot_Point_2D(est_p_a_emp,'ok','--k',1,3);
0454 
0455     plot(est_x_mean_a(1),est_x_mean_a(2),'ow','MarkerSize',12,'LineWidth',7);
0456     plot(est_x_mean_a(1),est_x_mean_a(2),'ok','MarkerSize',12,'LineWidth',3);
0457 
0458     plot(x_tilde.h(1)/x_tilde.h(3),x_tilde.h(2)/x_tilde.h(3),'+k','MarkerSize',10,'LineWidth',1);
0459 
0460     xlim_a = xlim;
0461     ylim_a = ylim;
0462 
0463     % geometric solution
0464     subplot(3,2,4)
0465     hold on
0466     title('SSDe')
0467     for n = 1:N_samples
0468         plot(est_x_mean_g(1)+(est_x_samples_g(n,1)-est_x_mean_g(1)),...
0469             est_x_mean_g(2)+(est_x_samples_g(n,2)-est_x_mean_g(2)),'.k');
0470     end
0471 
0472     sugr_plot_Point_2D(est_p_g_emp,'ok','--k',1,3);
0473 
0474     plot(est_x_mean_g(1),est_x_mean_g(2),'ow','MarkerSize',12,'LineWidth',7);
0475     plot(est_x_mean_g(1),est_x_mean_g(2),'ok','MarkerSize',12,'LineWidth',3);
0476 
0477     plot(x_tilde.h(1)/x_tilde.h(3),x_tilde.h(2)/x_tilde.h(3),'+k','MarkerSize',10,'LineWidth',1);
0478 
0479     xlim_g = xlim;
0480     ylim_g = ylim;
0481 
0482     % ml-estimation Hessian
0483 
0484     subplot(3,2,5)
0485     hold on
0486     title('MLEe')
0487     for n = 1:N_samples
0488         plot(est_x_mean_mH(1)+(est_x_samples_mH(n,1)-est_x_mean_mH(1)),...
0489             est_x_mean_mH(2)+(est_x_samples_mH(n,2)-est_x_mean_mH(2)),'.k');
0490     end
0491     sugr_plot_Point_2D(est_p_mH_emp,'ok','--k',1,3);
0492     plot(est_x_mean_mH(1),est_x_mean_mH(2),'ow','MarkerSize',12,'LineWidth',7);
0493     plot(est_x_mean_mH(1),est_x_mean_mH(2),'ok','MarkerSize',12,'LineWidth',3);
0494 
0495     plot(x_tilde.h(1)/x_tilde.h(3),x_tilde.h(2)/x_tilde.h(3),'+k','MarkerSize',10,'LineWidth',1);
0496 
0497     xlim_mH = xlim;
0498     ylim_mH = ylim;
0499 
0500     % ml-estimation
0501     subplot(3,2,6)
0502     hold on
0503     title('MLEs')
0504     for n = 1:N_samples
0505         plot(est_x_mean_ml(1)+(est_x_samples_ml(n,1)-est_x_mean_ml(1)),...
0506             est_x_mean_ml(2)+(est_x_samples_ml(n,2)-est_x_mean_ml(2)),'.k');
0507     end
0508     sugr_plot_Point_2D(est_p_ml_emp,'ok','--k',1,3);
0509 
0510     plot(est_x_mean_ml(1),est_x_mean_ml(2),'ow','MarkerSize',12,'LineWidth',7);
0511     plot(est_x_mean_ml(1),est_x_mean_ml(2),'ok','MarkerSize',12,'LineWidth',3);
0512 
0513     plot(x_tilde.h(1)/x_tilde.h(3),x_tilde.h(2)/x_tilde.h(3),'+k','MarkerSize',10,'LineWidth',1);
0514 
0515     % determine common plot bounding box
0516     xlim_ml = xlim;
0517     ylim_ml = ylim;
0518 
0519     mxlimg = [min([xlim_a(1),xlim_g(1)]),...
0520         max([xlim_a(2),xlim_g(2)])];
0521     mylimg = [min([ylim_a(1),ylim_g(1)]),...
0522         max([ylim_a(2),ylim_g(2)])];
0523 
0524     subplot(3,2,2);xlim(mxlimg);ylim(mylimg);
0525     subplot(3,2,4);xlim(mxlimg);ylim(mylimg);
0526 
0527     mxliml = [min([xlim_mH(1),xlim_ml(1)]),...
0528         max([xlim_mH(2),xlim_ml(2)])];
0529     myliml = [min([ylim_mH(1),ylim_ml(1)]),...
0530         max([ylim_mH(2),ylim_ml(2)])];
0531 
0532     subplot(3,2,2);xlim(mxlimg);ylim(mylimg);
0533     subplot(3,2,4);xlim(mxlimg);ylim(mylimg);
0534     subplot(3,2,5);xlim(mxliml);ylim(myliml);
0535     subplot(3,2,6);xlim(mxliml);ylim(myliml);
0536 
0537     % same bb for all
0538     mx = [min([xlim_a(1),xlim_g(1),xlim_mH(1),xlim_ml(1)]),...
0539         max([xlim_a(2),xlim_g(2),xlim_mH(2),xlim_ml(2)])];
0540     my = [min([ylim_a(1),ylim_g(1),ylim_mH(1),ylim_ml(1)]),...
0541         max([ylim_a(2),ylim_g(2),ylim_mH(2),ylim_ml(2)]) ];
0542 
0543     subplot(3,2,2);xlim(mx);ylim(my);
0544     subplot(3,2,3);xlim(mx);ylim(my);
0545     subplot(3,2,4);xlim(mx);ylim(my);
0546     subplot(3,2,5);xlim(mx);ylim(my);
0547     subplot(3,2,6);xlim(mx);ylim(my);
0548     
0549     %% evaluate correctness
0550     S = 0.99;
0551     check_estimation_result(R,x_tilde_e,Cxx_a_e,ones(N_samples,1),est_x_samples_a,S,' ALGs');
0552     check_estimation_result(R,x_tilde_e,Cxx_mH_e,sigma_2_mH,est_x_samples_mH,S,' MLEe');
0553     set(gcf,'Position',[0.25*ss(1),70,0.35*ss(1),0.25*ss(2)])
0554     check_estimation_result(R,x_tilde_e,Cxx_ml_e,sigma_2_ml,est_x_samples_ml,S,' MLEs');
0555     set(gcf,'Position',[0.63*ss(1),70,0.35*ss(1),0.25*ss(2)])
0556     
0557     % Bias and  accuracy
0558     disp('----------------------------')
0559     disp('Precision, bias and accuracy')
0560     lb = max([trace(est_x_cov_aE),...
0561               trace(est_x_cov_a),...
0562               trace(est_x_cov_g),...
0563               trace(est_x_cov_ml),...
0564               trace(est_x_cov_mH)]);
0565     
0566     f = 10^-(ceil(log(lb)/log(10)/2));
0567     factor_for_bias=1/f;
0568     
0569     % provide bias, accuracy and test statistic
0570     disp('sigma = sqrt(tr(CovM)/2)')
0571     disp('bias  = true_x - est_x')
0572     disp('A     = |bias|^2 + sigma^2)')
0573     disp(['Values * ',num2str(f),':'])
0574     ALGe_bias_x________y_____sigma_________A = ...
0575         f*[-x_tilde_e'+est_x_mean_aE,sqrt(trace(est_x_cov_aE)/2),...
0576         sqrt(norm(x_tilde_e'-est_x_mean_aE)^2+trace(est_x_cov_aE)/2)]      %#ok<*NOPTS>
0577     
0578     ALGs_bias_x________y_____sigma_________A = ...
0579         f*[-x_tilde_e'+est_x_mean_a,sqrt(trace(est_x_cov_a)/2),...
0580         sqrt(norm(x_tilde_e'-est_x_mean_a)^2+trace(est_x_cov_a)/2)]
0581     
0582     SSDe_bias_x________y_____sigma_________A = ...
0583         f*[-x_tilde_e'+est_x_mean_g,sqrt(trace(est_x_cov_g)/2),...
0584         sqrt(norm(x_tilde_e'-est_x_mean_g)^2+trace(est_x_cov_g)/2)]
0585     
0586     MLEs_bias_x________y_____sigma_________A = ...
0587         f*[-x_tilde_e'+est_x_mean_mH,sqrt(trace(est_x_cov_mH)/2),...
0588         sqrt(norm(x_tilde_e'-est_x_mean_mH)^2+trace(est_x_cov_mH)/2)]
0589     
0590     MLEe_bias_x________y_____sigma_________A = ...
0591         f*[-x_tilde_e'+est_x_mean_ml,sqrt(trace(est_x_cov_ml)/2),...
0592         sqrt(norm(x_tilde_e'-est_x_mean_ml)^2+trace(est_x_cov_ml)/2)]
0593 %%
0594 end
0595 % save('vp_0_200')

Generated on Sat 21-Jul-2018 20:56:10 by m2html © 2005