clear all
close all
load fisheriris
%Correlations between sepal and petal lengths
% for species  setosa, versicolor and virginica
n1=50; n2=50; n3=50; k=3; N=n1+n2+n3-3*k;
r =[ corr(meas(1:50, 1), meas(1:50, 3) ), ...
       corr(meas(51:100, 1), meas(51:100, 3) ), ...
       corr(meas(101:150, 1), meas(101:150, 3) ) ] 
    %0.2672    0.7540    0.8642
fisherz = @(r)  1/2 * log( (1+r)./(1-r) );
w=fisherz(r) 
%0.2738    0.9823    1.3098
wbar =  [n1-3   n2-3  n3-3]/N * w'   %0.8553
chi2 =   [n1-3,  n2-3, n3-3]*(w.^2)'- N*wbar^2  %26.3581 
pval = 1-chi2cdf(chi2, k-1)    %1.8897e-006


