0001
0002
0003
0004
0005
0006
0007
0008 function fig_16_13_profile_reconstruction_demo_precision()
0009
0010 addpath(genpath('../../General-Functions/'));
0011 addpath('Functions')
0012
0013 close all
0014
0015
0016 init_rand_seed(23);
0017
0018
0019 ss = plot_init;
0020
0021
0022 N = 200;
0023 sigma_e=0.5;
0024 sigma_n=0.5;
0025 factor_sigma = 1;
0026 type_outlier = 0;
0027 type_robust = [0,0,0,0];
0028 Niter = 0;
0029 print_type = 0;
0030 plot_type = 0;
0031
0032
0033 [x,y,select,xs,ys] = ...
0034 generate_observed_AR2_demo(N,sigma_e,sigma_n);
0035
0036
0037 [xest,aa,ab,ac,Cov] = estimate_profile_robust...
0038 (N,select,ys,sigma_e/factor_sigma,sigma_n,Niter,...
0039 type_outlier,type_robust,...
0040 plot_type,print_type);
0041
0042
0043
0044 factor = 1;
0045
0046 figure('name','Fig. 16.13: Profile Reconstruction and precision','color','w',...
0047 'Position',[0.2*ss(1),0.2*ss(2),0.5*ss(1),0.5*ss(2)]);
0048 hold on;
0049
0050
0051
0052
0053 xbandtop = x+3*factor*sqrt(diag(Cov));
0054 xbandbottom = x-3*factor*sqrt(diag(Cov));
0055 fill([(1:N)';(N:-1:1)'],[xbandtop;xbandbottom(end:-1:1)],[0.3,0.97,0.02],'FaceAlpha',0.5,'EdgeAlpha',0);
0056 plot(1:N,xest,'-k','LineWidth',2)
0057 plot(1:N,x,'--r','LineWidth',2)
0058 plot(1:N,xbandtop,'-r','LineWidth',1)
0059 plot(1:N,xbandbottom,'-r','LineWidth',1)
0060 plot(select,ys,'.b','MarkerSize',15)
0061 plot(1:N,xest,'.k','LineWidth',2)
0062 title(['Fig 16.13: $N = ',num2str(N),'$, $s_e = ',num2str(sigma_e),'$, $s_n =',num2str(sigma_e),'$'])
0063
0064
0065 return
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078 function [x,y,select,xs,ys] = ...
0079 generate_observed_AR2_demo(N,sigma_e,sigma_n)
0080
0081 x=zeros(N,1);
0082 y=zeros(N,1);
0083
0084 for n = 3:N
0085 x(n) = 1.9998*x(n-1)-0.9999*x(n-2)+randn(1)*sigma_e;
0086 y(n) = x(n)+randn(1)*sigma_n;
0087 end
0088 for i=1:N
0089 y(i) = y(i) - (i-1)*(x(N)-x(1))/(N-1);
0090 x(i) = x(i) - (i-1)*(x(N)-x(1))/(N-1);
0091 end
0092
0093 M = [6,12,24,81,95,124,138,176];
0094 select = zeros(8,1);
0095 xs = zeros(8,1);
0096 ys = zeros(8,1);
0097 for m = 1:8
0098 select(m) = M(m);
0099 xs(m) = x(M(m));
0100 ys(m) = y(M(m));
0101 end
0102
0103 return