in reply to Statistical data analysis
Your method of calculating variance can result in loss of significant
digits. For example, the following data produces a variance of 0 for
X on my machine (causing div-by-zero errors later). The variance
should be the same for both X and Y (as the data differs only by a
Better results may be achieved by "centering" your variance
calculation about the mean.
my $VX = 0;
$VX += ($_ - $MX)**2 for @x;
$VX /= $Xn;
You are also making far more passes over the data than necessary.