clear
close all
figure
set(gcf,'color',[1,1,1])

x=-4:0.01:4;
s=1;m=0;

P1=1/sqrt(2*pi)/s*exp(-(x-m).^2/2/s^2);
D1 = (1+erf((x-m)/s/sqrt(2)))/2;
s=sqrt(.8);m=0.5;
P2=1/sqrt(2*pi)/s*exp(-(x-m).^2/2/s^2);
D2 = (1+erf((x-m)/s/sqrt(2)))/2;
%
bp=0.43; 
ibp1 = find(abs(x+bp)==min(abs(x+bp)));
ibp2 = find(abs(x-bp)==min(abs(x-bp)));
%
[D1(ibp1),D2(ibp1)]
[1-D1(ibp2),1-D2(ibp2)]
%
for lam = [1,2,3,5]
  xx = (x + 10).^(lam);
  xx = xx/max(xx);
  
  h=plot(xx,[D1;D2]);
  set(h,'linewidth',5);
  set(h(1),'color',[0 0 0]+0.3)
  set(h(2),'color',[1 0 0])
  %hold on
  %h=area(xx(x<-bp),.45+0*P1(x<-bp));
  %set(h,'facecolor',[210 140 80]/255,'facealpha',.5)
  %h=area(xx(x>bp),.45+0*P1(x>bp));
  %set('facecolor',[80  220  85]/255,'facealpha',.5)
  %hold off
  %set(gca,'xlim',[xx(1),xx(end)])
  legend('climatology','forecast','location','northwest')
  %set(gca,'xtick',[])
  grid
  export_fig('-pdf',['shift_bc_cdf',num2str(lam,2)])

  h=plot(xx,[P1;P2]);
  set(h,'linewidth',5);
  set(h(1),'color',[0 0 0]+0.3)
  set(h(2),'color',[1 0 0])
  %hold on
  %h=area(xx(x<-bp),.45+0*P1(x<-bp));
  %set(h,'facecolor',[210 140 80]/255,'facealpha',.5)
  %h=area(xx(x>bp),.45+0*P1(x>bp));
  %set('facecolor',[80  220  85]/255,'facealpha',.5)
  %hold off
  %set(gca,'xlim',[xx(1),xx(end)])
  legend('climatology','forecast','location','northwest')
  %set(gca,'xtick',[])
  grid
  export_fig('-pdf',['shift_bc_',num2str(lam,2)])
  ylim=get(gca,'ylim');
  xlim=get(gca,'xlim');

  xx = (x + 10).^(lam);
  xx = xx/max(xx);
  
  h=plot(xx,[P1]);
  set(h,'linewidth',5);
  set(h(1),'color',[0 0 0]+0.3)
  %set(h(2),'color',[1 0 0])
  %hold on
  %h=area(xx(x<-bp),.45+0*P1(x<-bp));
  %set(h,'facecolor',[210 140 80]/255,'facealpha',.5)
  %h=area(xx(x>bp),.45+0*P1(x>bp));
  %set('facecolor',[80  220  85]/255,'facealpha',.5)
  %hold off
  %set(gca,'xlim',[xx(1),xx(end)])
  legend('climatology','forecast','location','northwest')
  %set(gca,'xtick',[])
  grid
  set(gca,'ylim',ylim,'xlim',xlim)
  export_fig('-pdf',['shift_climo_bc_',num2str(lam,2)])

  h=plot(xx,[D1]);
  set(h,'linewidth',5);
  set(h(1),'color',[0 0 0]+0.3)
  %set(h(2),'color',[1 0 0])
  %hold on
  %h=area(xx(x<-bp),.45+0*P1(x<-bp));
  %set(h,'facecolor',[210 140 80]/255,'facealpha',.5)
  %h=area(xx(x>bp),.45+0*P1(x>bp));
  %set('facecolor',[80  220  85]/255,'facealpha',.5)
  %hold off
  %set(gca,'xlim',[xx(1),xx(end)])
  legend('climatology','forecast','location','northwest')
  %set(gca,'xtick',[])
  grid
  set(gca,'xlim',xlim)
  export_fig('-pdf',['shift_climo_bc_cdf',num2str(lam,2)])

end

