NAME
Statistics::SerialCorrelation  calculate the serial correlation coefficient for an array
SYNOPSIS
use Statistics::SerialCorrelation;
print Statistics::SerialCorrelation::serialcorrelation(1..6);
Or if you don't mind polluting your namespace, you may import the serialcorrelation function like so:
use Statistics::SerialCorrelation 'serialcorrelation';
DESCRIPTION
This module does just one thing, it calculates Serial Correlation Coefficients, which are a measure of how predictable a series of values is. For example, the sequence:
1 2 3 4 5 6 7 8 9 10
is very predictable, and will have a high serial correlation coefficient. The sequence
10 1 3 2 6 7 7 9 2
is less predictable and so has a correlation coefficient nearer 0.
In general, random data has a coefficient close to zero, highlyordered data doesn't. Note that the coefficient may be negative.
There is just one function.
 serialcorrelation

This takes either a list of numbers or an array reference. If given an array reference, this is first turned into an array. It then calculates the correlation coefficient and returns it.
See your copy of Knuth for the formula.
BUGS
To avoid dividebyzero errors, we return undef if the square of the sum of your values is equal to the number of values multiplied by the sum of the squares of the values. undef was chosen because it will never otherwise be returned and so you can easily detected.
The results are not particularly meaningful for small data sets.
No other bugs are known, but if you find any please let me know, and send a test case.
FEEDBACK
I welcome feedback about my code, including constructive criticism.
AUTHOR
David Cantrell <david@cantrell.org.uk>
COPYRIGHT
Copyright 2003 David Cantrell
This module is freeasinspeech software, and may be used, distributed, and modified under the same terms as Perl itself.