[Haskell-cafe] Period of a sequence

Richard O'Keefe ok at cs.otago.ac.nz
Tue Jun 28 03:19:56 CEST 2011

On 27/06/2011, at 8:32 PM, Steffen Schuldenzucker wrote:

> On 06/26/2011 04:16 PM, michael rice wrote:
>> MathWorks has the function seqperiod(x) to return the period of sequence
>> x. Is there an equivalent function in Haskell?
> Could you specify what exactly the function is supposed to do?

Google turns up the documentation pretty quickly.
"The period p is computed as the minimum length of a subsequence x(1:p)
 of x that repeats itself continuously every p samples in x."
(The misuse of the word "continuously" is theirs, not mine.)

Incomplete repetitions at the end are allowed, so by that definition
every finite sequence _has_ a period which can be found in quadratic time.

The times I've wanted something like this, the data have been noisy
enough that the implied algorithm would have been guaranteed to be useless.

More information about the Haskell-Cafe mailing list