Working in C#, I need to find all local peaks in a List of doubles and return them as another List doubles. This seems simple enough if I have a set number of values I'm comparing in any given 'window' of values, but I need to be able to actually pass this window size into the function itself. That may be confusing, but basically I need something like this:
public List<double> FindPeaks(List<double> values, double rangeOfPeaks)
where if 'rangeOfPeaks' was 5, the 'current' value would be compared to 2 values on each side of it to determine if it was a peak or not. If 'rangeOfPeaks' was 11, the current value would be compared to 5 values on each side. I'd think this was a pretty basic algorithm, however, I've been unsuccessful in finding any good methods for detecting a peak like this. Has anyone ever done this before? Any help at all would be appreciated. Thanks in advance!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…