Finding Mount Everest
Here’s a simple way to find the peaks in a time series. It’s what I used to label holidays in The Rhythm of Food.
You have an array of data points (samples). Compute a peak score for each sample by comparing it to its shortest neighbors on each side. The bigger the difference, the higher the score.
Each sample now has a score, and we want to use them to filter the peaks. Apply a sensitivity thrshold to the scores to pick out the globally strongest peaks.
To prevent peaks that span multiple samples from appearing multiple times in the final list, coalesce peaks that are close together.
Algorithm Notes — This idea comes from a paper on simple algorithms for peak detection. I like this approach for its minimalism and because it’s often good enough. If needed, more sophisticated techniques exist.