Usually people use
scipy.signal to detect peak in signal.
scipy.signal.find_peaks_cwt( vec )
which returns list of index where vec has maximas. However this does not work all
the time, especially when vector is noisy. I could not get it working very well to compute the modality of distributions.
This is the most sophisticated library (AFAIK): https://gist.github.com/sixtenbe/1178136
Its can be installed via pip:
$ pip install analytic_wfm
>>> import analytic_wfm >>> vec # this is the 1d array in which I want to detect peaks. >>> maxPeaks, minPeaks = analytic_wfm.peakdetect( vec, lookahead = 10 )
This returns maximum peaks and minimum peaks. There are various other functions
described in readme.txt file.
Here is an example where I used this library to compute modality of a distribution: