Finding local minima and maxima of a graph

François Chaplais francois.chaplais at mines-paristech.fr
Sun Dec 5 16:33:26 EST 2010


I have had a similar request from my son who wanted to isolate "significant" peaks in data (coming from biological experiments). I gave him a helping hand in doing the preprocessing that removes the variations that are "not significant". It did, however, some time to explain this, but he got it, and finally we managed to explain it to his boss in the project. However I do not feel doing a similar thing by mail.
The summary is: you do a decomposition between a component that varies rather slowly and different "details" that represent the faster variations ("faster" if you are in the time domain). To keep only the significant variations, you  remove the "details" that are below a certain threshold, keep the others, and reconstruct a signal by using the "slow" component and the "significant" details.
This is only preprocessing; after that, you have to detect the remaining maxima.
This assumes that the maxima you are seeking are both well located in time and of large magnitude.
This is an application of wavelet theory (see http://cas.ensmp.fr/~chaplais/Wavetour_presentation/Wavetour_presentation_US.html for a short tutorial).
The moving average stuff is a particular case of this (it is the Haar basis).
I know this will not help you immediately, but this difficult to explain very well in a single mail.
Also, there are classes of processing that mostly require only integer arithmetics. This is because they are based on some interpolation on an integer grid. Since the latter is a linear problem with integer coefficient, its solution is rational with a common denominator being the determinant of the related matrix.
Very best,
	François
Le 5 déc. 2010 à 06:45, Jerry J a écrit :

> 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.
> 
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list