I have a list of dates in which a certain event happened. Taking into consideration that a particular occurrence of the event can:
- Be a one time thing or
- Be part of a periodic series, which happens every N months, where N is an integer
I want to classify and group the dates as they relate to each other. That is, I want to be able to detect when a periodic series is happening and which of the dates in the set belong to that periodic series and which ones are one-time events.
Examples:
20/01/2016, 20/02/2016, 20/03/2016, 20/04/2016
is a set of events which happen once a month.20/01/2016, 25/01/2016, 20/02/2016, 20/03/2016, 20/04/2016
is a set of events which happen once a month, with the exception of the second one, which is a one-time-only event.20/01/2016, 20/03/2016, 20/04/2016, 20/05/2016, 20/07/2016
is a set of events which happen once every two months, with the exception of the third event, which is a one-time-only event.
I realise that it is not possible to create a conclusive algorithm (who is to say the last example does not show three different streams of events: one happening every two months, until 20/03/2016; then one happening every month until 20/05/2016; and finally a one-time event at 20/07/2016?), but I was wondering if there is some known algorithm which can do these kind of frequency-detection, even if non-conclusively.
Happy to implement the algorithm myself if it's easy enough and explained in detail. If libraries are necessary, please consider the project is in Python.