Another in a series of example F# programs that may be of use.
A common task is looking for zones. Not all zones are found in the same way. Sometimes you may be looking for zones where the behavior is different from surrounding zones (e.g., higher or lower values of something), sometimes the zones are abrupt changes in behavior (e.g., looking for the start of an earthquake for example in near real-time).
In both of these cases we have to define zones, and some measure of what is going on in the zone. In some data sets we can sample at even intervals with no breaks, that is not always the case, so here the zonations functions do no rely on uniformly spaced data, and work even with missing data (although, the analysis of the zone may not be the best).
So, what data structure to use! Modern programming languages give us various different structures, rather than just arrays. Here I decided to use lists of tuples. Each tuple is a date-time and a value (here a length). My zones are based on date ranges, and my functions are looking for zones based on a length.
Depending on the signal that is being used, some form of filtering may be needed to eliminate noise. One of the functions in zone.fs is a simple moving average filter. Another looks for "outliers" and removes then based on the mean and standard deviation.
One of the functions looks for changes in the ratio of short-term and long-term averages (STA/LTA). It is commonly used in "triggering" a monitoring system, such as watching real-time for an earthquake. In general, it looks for an abrupt change in the signal.