itload('../merger_debug.it');

ndat = 1000; % check if true!

figure(1);
for it=0:6
    figure(it+1)
    subplot(2,2,1);
    hold off
    si = num2str(it);
    eval(['plot3(Smp' si '(1,:),Smp' si '(2,:),exp(Mpdf' si '),''r.'')']);
    if i==0, title('Proposal & mix'); end
    set(gca,'XLim',[-10,10]);
        
    subplot(2,2,2);
    hold off
    eval(['contour_2(Smp' si '(1,:),Smp' si '(2,:),exp(lW' si '(1,:)))']);
%    hold on
%    eval(['plot3(Smp' si '(1,:),Smp' si '(2,:),w' si ',''r.'')']);
    if i==0, title('Weighed Smp'); end
    
    subplot(2,2,3);
    hold off
    eval(['contour_2(Smp' si '(1,:),Smp' si '(2,:),exp(lW' si '(2,:)))']);
%    eval(['plot3(Smp' si '(1,:),Smp' si '(2,:),w' si ',''.'')']);
%    hold on
%    eval(['plot3(Smp' si '(1,:),Smp' si '(2,:),w_is_' si ',''r.'')']);
    if i==0, title('Weighed Smp'); end
    
    
    subplot(2,2,4);
    eval(['contour_2(Smp' si '(1,:),Smp' si '(2,:),w' si ')']);
    if i==0, title('Resampled hist'); end
    
  %  keyboard
end

   
itload('../merger_iter_test.it');
XG = reshape(Grid(1,:),Npoints,Npoints);
YG = reshape(Grid(2,:),Npoints,Npoints);

figure(it+2);
M1 = reshape(exp(Res1),Npoints,Npoints);
contour(XG,YG,M1);

figure(it+3);
M2 = reshape(exp(Res2),Npoints,Npoints);
contour(XG,YG,M2);

figure(it+4);
L1 = reshape(exp(lf1),Npoints,Npoints);
contour(XG,YG,L1);
