result = find_peaks(x, [height=], [distance=], [prominence=], [width=], [rel_height=0.5])
Input: x, height, distance, prominence, width, rel_height · Output: result
What it is
x is a length-N vector. height (optional number): minimum peak value; distance (optional number, samples): minimum separation, enforced greedily by height so a close cluster keeps its tallest member; prominence (optional number): minimum rise above surrounding terrain (the real bounding-minima computation, not just local-maxima detection); width (optional number, samples): minimum width at rel_height (default 0.5, i.e. half-prominence) of the peak's prominence below its height, via linear interpolation of the crossing — matches scipy.signal.find_peaks's own algorithm. Kwarg names match SciPy; the original min_height/min_distance/min_prominence names are still accepted as aliases.
Overloads
One call shape — this function is not overloaded.
Code
Input
Output
Description
result = find_peaks(x, [height=], [distance=], [prominence=], [width=], [rel_height=0.5])
distancenumber, optionaldistance (optional number, samples): minimum separation, enforced greedily by height so a close cluster keeps its tallest member.
prominencenumber, optionalprominence (optional number): minimum rise above surrounding terrain (the real bounding-minima computation, not just local-maxima detection).
widthnumber, optionalwidth (optional number, samples): minimum width at rel_height (default 0.5, i.e.
rel_heightnumber, optional (default 0.5)width (optional number, samples): minimum width at rel_height (default 0.5, i.e.
resultvector
Returns a vector of 0-indexed integer indices into x, one per surviving local maximum.
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
peaks = find_peaks(spectrum, min_height=0.1, min_distance=5)
find_peaks(x, [height=], [distance=], [prominence=], [width=], [rel_height=]) — indices of x's local maxima, optionally filtered by height, minimum separation (samples — enforced greedily by height, so a close cluster keeps its tallest member), prominence (how much a peak rises above its own surrounding terrain, not just its absolute height — numeric::transforms::find_peaks's own real bounding-minima computation, not a shortcut), and now width (the peak's width, in samples, at rel_height — default 0.5 — of its prominence below the peak, computed by linear interpolation around the crossing exactly as scipy.signal.peak_widths does; see numeric::transforms::peak_width's own doc comment). Kwarg names match scipy.signal.find_peaks (height/distance/prominence/width) — the original min_height/min_distance/min_prominence names are kept as accepted aliases so existing scripts keep working unchanged. Returns just the peak indices (a plain Vec, not SciPy's (peaks, properties) pair — Qu has no tuple-return for that shape here); findpeaks below is the enriched, multi-field alternative when prominence/width VALUES (not just filters) are wanted.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.