[SciPy-user] Extrema finding

dan collins uchsc dan.collins at uchsc.edu
Thu Oct 9 10:33:19 EDT 2008


I use the following technique to fine minima and maxima.
x = 1d vector
y = x; y = delete(y, [0], axis=0); y = append(y,0)
xy = x-y
a = [0]
for i in range(0, size(xy)):
    a = append(a,xy[i]-xy[i+1])

minima = where(a == 2)
maximu = where(a == -2)

>
>
>
> Message: 7
> Date: Thu, 9 Oct 2008 12:44:16 +0100
> From: iCy-fLaME <icy.flame.gm at gmail.com>
> Subject: [SciPy-user] Extrema finding
> To: "SciPy Users List" <scipy-user at scipy.org>
> Message-ID:
>        <bfb379e10810090444i4e435eb8q5f5729005087881b at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> I am trying to find a list of all maxima and minima, each for a given
> (1D) numpy array. Anyone know of a quick way to do it?
>
> Ideally the function will return the extrema values and their
> positions. Relatively simple function to implement in Python, but that
> would be painfully slow. The typical data array I am looking at, has
> approximately 500k elements of double precision float.
>
> Any thoughts and suggestions are much appreciated. Thanks!
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20081009/e8beed44/attachment.html>


More information about the SciPy-User mailing list