clear
set(gcf,'color',[1,1,1])
nt = 30;
mc=1000
for l=0:7;
  for im=1:mc
    y = randn(1,nt);
  for ii=1:nt
    ind = setdiff([1:nt],[(ii-l):(ii+l),ii]);
    yp(ii) = mean(y(ind));
  end    
  c(l+1,im) = corr2(yp,y);
  e(l+1,im) = mean((yp-y).^2);
  ec(l+1,im) = mean((mean(y)-y).^2);
  
  end
end


bar([0:7]*2+1,mean(c,2)) 
xlabel('number left out')
title('cross-validated correlation of climatology forecast')

filename='bias_climo_cv';
export_fig('-pdf',filename)



bar([0:7]*2+1,1-mean(e,2)./mean(ec,2)) 
xlabel('number left out')
title('cross-validated 1-normalized error variance')

filename='bias_climo_cv_ev';
export_fig('-pdf',filename)



