%
close all
clear all
%-----------------------------------
 disp('Fisher z-transform: Simulations')
  lw = 2; 
  set(0, 'DefaultAxesFontSize', 17);
  fs = 17;
  msize = 5;
randn('seed',1)

M=10000; n=40;
rs =[];
for i = 1:M
    x1 = randn(n,1);
    x2 = randn(n,1);
    r=corr(x1, (x2+x1));
    rs = [rs r];
end
figure(1)
 histo(rs, 80, 0, 1);
%print -depsc 'C:\Springer\Corr\Correps\figz1.eps'
figure(2)
zs = 1/2 * log((1+rs)./(1-rs));
 histo(zs, 80, 1, 1);
hold on
mu = atanh(sqrt(2)/2);
var = 1/(n-3);
xx=linspace(0,2,100);
yy=normpdf(xx, mu, sqrt(var));
%yy=1/sqrt(2*pi*var) .* exp( - (xx - mu).^2/(2*var));
plot(xx, yy, 'r--', 'linewidth',lw)
histo(zs, 80, 1, 1);
%print -depsc 'C:\Springer\Corr\Correps\figz2.eps'
