# Identifying Periodic Behavior

Attached is an algorithm that can identify periodic behavior in data, and cluster the data, with values that appear in the same stage of the sequences identified being clustered together. The command line contains a simple example where a binary string has a known gap between the bits set to ‘1’, and the algorithm is tasked with identifying the size of the gap between the ‘1’s, thereby identifying the period of the dataset.

For example, the string $s = 100100100 ...$ has a gap of two between each of the ‘1’s, and the algorithm can identify this type of structure in polynomial time. You can then use basic modular arithmetic to predict entries beyond the observed dataset, assuming the patterns hold.

You can have multiple periods, you can add noise, and in a follow up article, I’ll combine this algorithm with my thermodynamics software, which will allow the algorithm to identify the cycles in a combustion engine. This is actually quite easy, and all you need to do is substitute the operator in the attached code with my mass-classification operator. This software would probably be useful for astronomy as well, since astronomers deal with complex cyclical phenomena all the time, due to orbits, rotations, etc.

8_24_CMNDLINE

linear_clustering