Dave's Free Press

Technology: Statistics-SerialCorrelation-1.1

 

Older stuff

Statistics::SerialCorrelation - calculate the serial correlation co-efficient for an array


NAME

Statistics::SerialCorrelation - calculate the serial correlation co-efficient 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 Co-efficients, 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 co-efficient. The sequence

    10 1 3 2 6 7 7 9 2

is less predictable and so has a correlation co-efficient nearer 0.

In general, random data has a co-efficient close to zero, highly-ordered data doesn't. Note that the co-efficient 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 co-efficient and returns it.

See your copy of Knuth for the formula.


BUGS

To avoid divide-by-zero 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 free-as-in-speech software, and may be used, distributed, and modified under the same terms as Perl itself.