[SciPy-user] Extrema finding

dan collins uchsc dan.collins@uchsc....
Thu Oct 9 09:33:19 CDT 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@gmail.com>
> Subject: [SciPy-user] Extrema finding
> To: "SciPy Users List" <scipy-user@scipy.org>
> Message-ID:
>        <bfb379e10810090444i4e435eb8q5f5729005087881b@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://projects.scipy.org/pipermail/scipy-user/attachments/20081009/e8beed44/attachment.html 


More information about the SciPy-user mailing list