Finding local minima and maxima of a graph

Jerry J jhj at jhj.com
Sun Dec 5 00:45:00 EST 2010


Yes, what Jonathan wrote.

The folks who do heavy computing in the audio world do something called windowing. Thats like a rolling average, except weighted toward the "center". Choosing the width of the window and the algorithm for determining its shape can get complicated, and has been greatly studied. You probably don't need such detail - in audio they are often doing FFT stuff to the frequency domain and back so the shape is critical and complicated. Possibly you could simplify the concept using a triangular approach which would involve a whole lot less computation. The math is not impenetrable, but can get slow in LC. 

--Jerry J

On Dec 4, 2010, at 9:19 PM, Jonathan Lynch wrote:

> Hi Bryan,
> 
> The first step is to define a local minimum or maximum for this situation.
> 
> Plotting a 3-day rolling average would be pretty straight forward. Is three
> days sufficient?
> 
> You could get a 5-day rolling average, then pick five day averages that are
> are greater than, or less than, their neighboring 5-day averages. You would
> not do this by comparing successive discreet 5-day periods, though. Instead,
> each 5-day period needs to overlap its neighbors by 4 days - does that make
> sense?
> 
> Also, consider this. You could just look for peaks and valleys that are
> greater or less than all neighbors within 5 days, or within 10 days. Only
> the standout data points would show up in that circumstance.
> 
> I would be wary of trying to approximate your data set with a simple
> formula, like a sine wave. If you can come up with a good fit, then maybe -
> but don't settle for a rough fit.
> 
> 
> On Sat, Dec 4, 2010 at 11:32 PM, Bryan McCormick <bryan at deepfoo.com> wrote:
> 
>> Jerry,
>> 
>> Yes, that would be far too many hits and there has to be some scaling
>> applied as a filter for that reason. The criteria more precisely is
>> "significant" peak and trough values. With significant being the trick. For
>> example, is the peak or trough 3 percent or more away.
>> 
>> There is a seasonal and/or trend component to the data. So I think step one
>> has to be detrending the series first. If you happen to have a good notion
>> of how to write a least-squares fit that would be a great. I'll then be able
>> to isolate the peaks and troughs by differencing from that line.






More information about the use-livecode mailing list