Eric Weeks - personal pages - software

Software to find local minima & maxima in a time series

[home] [research]
[software] [pics]
[misc/links] [about me]

This software examines data to find local minima & maxima. The first version of this was written by Tom Solomon, and I have added on a few simple features. Click here for an example of how I have used this program.

Click here to download software. To compile, use "cc -o minmax minmax.c -lm".

To use the software, you can either specify the filename or pipe the data into the program:

cat datafile | minmax > output.dat


minmax datafile > output.dat

There are several options. -h lists all the options with a brief comment to remind you what they do.

simple features: -h : help -- lists all options -p : input data is in x-y pairs; look for extrema of y -m : look for maxima only [default: print both] -M : look for minima only [default: print both] -e : print out first and last point extended features: -w # : use a small window of this width (see below) -s : use > = for comparison rather than >

The basic alogorithm is that the program checks the local slope; if it changes sign, print out the extremum point where the sign change occurs. A different way of putting it is that it examines a point and its two neighbors; if the point is larger than both neighbors then it is a local maximum, and if smaller than both neighbors it is a local minimum.

The more complicated algorithm is activated by using the -w option. Specifying -w 4 requires that a point must be larger than the four points before it, and the 4 points after it, in order to count as a maximum (likewise for a minimum).

NOTE: There are several undocumented features. You may examine the source code if you want to figure out what they do. Brief hints of what they do: -W # sets a larger window size (if the difference between the largest and smallest values within the small window are less than 0.02, use this larger window size instead for that point); -t # changes the value 0.02 used to switch to the larger window size; -n adds 1% noise to the data to help create a local peak in what might otherwise be a plateau; -f # takes a moving range of data and averages it, replacing the middle point in the range with the average -- this is effectively a low-pass filter; -d turns on some debug features which I am not completely sure of. Despite this description of these features, consider them "undocumented" unless you examine the source code yourself to determine their usefulness!

If you have questions, please send me email; email address below.

Some links...

Current address:
Eric R. Weeks
Department of Physics
Emory University
Atlanta, GA 30322-2430