0

Possible Duplicate:
Running maximum of numpy array values

Is there a built in numpy function which does this?

def peak_track(array):
    max = 0
    max_array = np.zeros_like(array)
    for i, val in enumerate(array):
        if val > max:
            max = val
        max_array[i] = max
    return max_array
Community
  • 1
  • 1
Ferguzz
  • 5,777
  • 7
  • 34
  • 41
  • Check the documentation and find out ! – Minion91 Sep 26 '12 at 10:15
  • obviously I have tried but I can't find it based on my searches, hence the question! – Ferguzz Sep 26 '12 at 10:17
  • So you can't find it? If only there was some way to deduce that observation to an answer to your question. – Minion91 Sep 26 '12 at 10:18
  • i don't understand what you are trying to say. i think it's a fairly reasonable question. there are plenty of similar ones e.g. http://stackoverflow.com/questions/9312756/is-there-a-numpy-max-min-function http://stackoverflow.com/questions/1713335/peak-finding-algorithm-for-python-scipy – Ferguzz Sep 26 '12 at 10:21
  • Those are imho bad questions aswell – Minion91 Sep 26 '12 at 10:23
  • [This one](http://stackoverflow.com/q/7251421/1240268) however is an exact duplicate :) – Andy Hayden Sep 26 '12 at 10:28
  • Google `numpy peak detection` and get links to SO and that algorithm : https://gist.github.com/1576079 – Pierre GM Sep 26 '12 at 10:30
  • thanks hayden, just a case of the name - running maximum was what I was looking for! – Ferguzz Sep 26 '12 at 10:32

0 Answers0