Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
8 events
when toggle format what by license comment
Jun 23, 2021 at 23:40 comment added Reed Espinosa @ankostis Note that simply removing the +1 and substituting np.gradient() for np.diff in the code above produces the indices of each minima/maxima as well as their lowest/highest neighbors.
Oct 27, 2017 at 16:27 review Suggested edits
Oct 27, 2017 at 17:39
May 31, 2016 at 18:15 history edited Cleb CC BY-SA 3.0
removed fluff, highlighting
Jun 23, 2015 at 17:18 comment added marcman I know this thread is years old, but it's worth adding that if your curve is too noisy, you can always try low-pass filtering first for smoothing. For me at least, most of my local max/min uses are for global max/min within some local area (e,g, the big peaks and valleys, not every variation in the data)
Jan 30, 2015 at 13:41 comment added ankostis To avoid this +1 instead of np.diff() use np.gradient().
Mar 24, 2013 at 21:06 comment added tktk This will also act weird if there are repetitive values. e.g. if you take the array [1, 2, 2, 3, 3, 3, 2, 2, 1], the local maxima is obviously somewhere between the 3's in the middle. But if you run the functions you provided you get maximas at indices 2,6 and minimas at indices 1,3,5,7, which to me doesn't make much sense.
Feb 28, 2013 at 17:09 comment added danodonovan nice use of nested numpy functions! but note that this does miss maxima at either end of the array :)
Mar 12, 2012 at 12:35 history answered R. C. CC BY-SA 3.0