[SciPy-user] Finding local minima of greater than a given depth
Zane Selvans
zane at ideotrope.org
Thu Aug 14 15:40:18 EDT 2008
Is there a function within scipy somewhere which will, given an array
representing values of a function, find all the local minima having a
depth greater than some specified minimum? The following works great
for smooth functions, but when the data has noise in it, it also
returns all of the (very) local minima, which I don't want. The
functions I'm working with are periodic (hence the modulo in the
indices for endpoint cases). Or, if there isn't such a built in
functionality, what's the right way to measure the depth of a local
minimum?
def local_minima(fitlist):
minima = []
for i in range(len(fitlist)):
if fitlist[i] < fitlist[mod(i+1,len(fitlist))] and fitlist[i]
< fitlist[mod(i-1,len(fitlist))]:
minima.append(fitlist[i])
minima.sort()
good_indices = [ fitlist.index(fit) for fit in minima ]
good_fits = [ fit for fit in minima ]
return(good_indices, good_fits)
--
Zane Selvans
Amateur Earthling
http://zaneselvans.org
zane at ideotrope.org
303/815-6866
PGP Key: 55E0815F
More information about the SciPy-User
mailing list