| 1 | itload('iter_cond_debug.it'); |
|---|
| 2 | |
|---|
| 3 | ndat = 1000; % check if true! |
|---|
| 4 | |
|---|
| 5 | XL = [-3 3]; |
|---|
| 6 | YL= XL; |
|---|
| 7 | |
|---|
| 8 | iters =[];% [0 2 39] |
|---|
| 9 | |
|---|
| 10 | figure(1); |
|---|
| 11 | niters = length(iters); |
|---|
| 12 | noi = 1; |
|---|
| 13 | for it=iters |
|---|
| 14 | % figure(it+1) |
|---|
| 15 | subplot(5,niters,noi); |
|---|
| 16 | si = num2str(it); |
|---|
| 17 | eval(['contour_2(Smp' si '(1,:),Smp' si '(2,:),exp(Mpdf' si '''))']); |
|---|
| 18 | if it==iters(1), |
|---|
| 19 | ylabel('Proposal density '); |
|---|
| 20 | end |
|---|
| 21 | set(gca,'XLim',XL); |
|---|
| 22 | set(gca,'YLim',YL); |
|---|
| 23 | |
|---|
| 24 | subplot(5,niters,noi+niters); |
|---|
| 25 | eval(['contour_2(Smp' si '(1,:),Smp' si '(2,:),exp(lW' si '(1,:)))']); |
|---|
| 26 | if it==iters(1), |
|---|
| 27 | ylabel('First source'); |
|---|
| 28 | end |
|---|
| 29 | set(gca,'XLim',XL); |
|---|
| 30 | set(gca,'YLim',YL); |
|---|
| 31 | |
|---|
| 32 | subplot(5,niters,noi+2*niters); |
|---|
| 33 | eval(['contour_2(Smp' si '(1,:),Smp' si '(2,:),exp(lW' si '(2,:)))']); |
|---|
| 34 | if it==iters(1), |
|---|
| 35 | ylabel('Second source'); |
|---|
| 36 | end |
|---|
| 37 | set(gca,'XLim',XL); |
|---|
| 38 | set(gca,'YLim',YL); |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | subplot(5,niters,noi+3*niters); |
|---|
| 42 | hold off |
|---|
| 43 | eval(['contour_2(Smp' si '(1,:),Smp' si '(2,:),w' si ''')']); |
|---|
| 44 | if it==iters(1), |
|---|
| 45 | ylabel('Merged density'); |
|---|
| 46 | end |
|---|
| 47 | set(gca,'XLim',XL); |
|---|
| 48 | set(gca,'YLim',YL); |
|---|
| 49 | |
|---|
| 50 | subplot(5,niters,noi+4*niters); |
|---|
| 51 | hold off |
|---|
| 52 | eval(['contour_2(Smp' si '(1,:),Smp' si '(2,:),exp(lw_m' si '''))']); |
|---|
| 53 | if it==iters(1), |
|---|
| 54 | ylabel('Importance density'); |
|---|
| 55 | end |
|---|
| 56 | set(gca,'XLim',XL); |
|---|
| 57 | set(gca,'YLim',YL); |
|---|
| 58 | noi = noi+1; |
|---|
| 59 | end |
|---|
| 60 | |
|---|
| 61 | prop_mean=zeros(2,40); |
|---|
| 62 | prop_var=zeros(2,40); |
|---|
| 63 | for it=0:39 |
|---|
| 64 | si = num2str(it); |
|---|
| 65 | eval(['eff_w(it+1) = 1/(w' si '''*w' si ');']); |
|---|
| 66 | eval(['prop_mean(1:2,it+1) = Mpred_mean' si ';']); |
|---|
| 67 | eval(['prop_var(1:2,it+1) = Mpred_var' si '(1:2);']); |
|---|
| 68 | end |
|---|
| 69 | |
|---|
| 70 | figure(2) |
|---|
| 71 | subplot(1,2,1) |
|---|
| 72 | hold off |
|---|
| 73 | plot(eff_w) |
|---|
| 74 | xlabel('iteration'); |
|---|
| 75 | ylabel('Effective sample size'); |
|---|
| 76 | %title('Non-normalized importance weights') |
|---|
| 77 | |
|---|
| 78 | subplot(1,2,2); |
|---|
| 79 | hold off |
|---|
| 80 | plot(prop_mean'); |
|---|
| 81 | hold on |
|---|
| 82 | plot(prop_mean'+2*sqrt(prop_var'),'.'); |
|---|
| 83 | plot(prop_mean'-2*sqrt(prop_var'),'.'); |
|---|
| 84 | |
|---|
| 85 | %plot(ones(size(prop_mean,2),1)*[3 2],'--') |
|---|
| 86 | xlabel('iteration'); |
|---|
| 87 | title('Mean value of the joint merger $\tilde{f}(\bm{x})$'); |
|---|
| 88 | |
|---|
| 89 | % itload('../merger_iter_test.it'); |
|---|
| 90 | % XG = reshape(Grid(1,:),Npoints,Npoints); |
|---|
| 91 | % YG = reshape(Grid(2,:),Npoints,Npoints); |
|---|
| 92 | % |
|---|
| 93 | % figure(2); |
|---|
| 94 | % M1 = reshape(exp(Res1),Npoints,Npoints); |
|---|
| 95 | % contour(XG,YG,M1,7); |
|---|
| 96 | % |
|---|
| 97 | % figure(3); |
|---|
| 98 | % hold off |
|---|
| 99 | % mm = max(max(Res2)); |
|---|
| 100 | % for i=1:size(Res2,1) |
|---|
| 101 | % M2 = reshape(Res2(i,:),Npoints,Npoints); |
|---|
| 102 | % contour(XG,YG,M2,[0:mm/7:mm]); |
|---|
| 103 | % hold on |
|---|
| 104 | % end |
|---|
| 105 | |
|---|