# Finding local minima and maxima of a graph

Jerry J jhj at jhj.com
Sat Dec 4 23:07:42 EST 2010

```On Dec 4, 2010, at 7:38 PM, Bryan McCormick wrote:

> Peter, Jonathan
>
> I had thought to use a sin function on the time series to find peak and trough values. I would filter the sin function results for those close to 1 or -1, though I am not sure what the filter interval will be just yet.
>
> Then, I would be able to grab the value from the actual time series from the date array walking the sin function results would produce.
>
> Does this seem like a valid means to do this? In terms of programming it would be a breeze, but is it a valid method?

Maybe I don't understand the problem completely. If local minima and maxima are the only criteria, could you just look at differences between pairs of points and watch for the difference to change sign? Thats the slope as close to the data as you can get.

As example:
point 3 minus point 4 is poisitive
point 4 minus point 5 is poisitive
point 5 minus point 6 is NEGATIVE -- aha point 5 was a local minimum.
etc. and vice versa.

If that makes too many hits, the raw data could be smoothed by various methods, some quite simple.

--Jerry Jensen

```