2 stable releases
1.0.1 | May 26, 2022 |
---|---|
1.0.0 | Oct 7, 2021 |
#1652 in Algorithms
Used in pitch-detector
12KB
210 lines
PeakFinder
A library for identifying peaks in line data with implementations in multiple languages. The line data could be from accelerometer data, spectral data, stock price history, almost anything.
Here's a graphical example of how this works, indentifying the peaks and troughs in the given line data. The blue line is the original data and the green line shows the peaks identified by the algorithm:
The library is designed to be small and easy to use, with little or no dependencies (the python implementation requires numpy). It currently has interfaces for finding peaks where the maximum value exceeds a specified threshold as well as peaks above a given statistical limit. Additional algorithms may be added in the future.
Installation
C++
Copy the files Peaks.cpp
and Peaks.h
into your project. Look at main.cpp
for an example of how to use the peak finding class.
GraphPeakList Peaks::findPeaksOverThreshold();
GraphPeakList Peaks::findPeaksOverStd();
Julia
Copy the file Peaks.jl
into your project. Look at PeakFinder.jl
for an example of how to use the peak finding class.
find_peaks_over_threshold(data::Array{GraphPoint}, threshold)
find_peaks_over_stddev(data::Array{GraphPoint}, sigmas)
Python
Copy the file peaks.py
into your project, though I will eventually create a pip
installable package for it. Read peakfinder.py
to see example usage.
find_peaks_in_numeric_array_over_threshold(data, threshold)
find_peaks_in_numeric_array_over_stddev(data, sigmas)
Rust
Install the cargo package peak_finder
. If you really don't want the package dependency, you could just copy the file peaks.rs
into your project. Look at lib.rs
for example usage. The available functions are:
find_peaks_in_numeric_array_over_threshold(data, threshold)
find_peaks_in_numeric_array_over_stddev(data, sigmas)
Version History
v.1.0.0 - Initial release.
License
This library is released under the MIT license, see LICENSE for details.
Dependencies
~1.2–1.6MB
~19K SLoC