PeakDetect[list]
gives a binary list in which 1s correspond to peak positions in list.
PeakDetect[list,σ]
detects peaks that survive Gaussian blurring up to scale σ.
PeakDetect[list,σ,s]
detects peaks with minimum sharpness s.
PeakDetect[list,σ,s,t]
detects only peaks with values greater than t.
PeakDetect[list,σ,{s,σs},{t,σt}]
uses different scales for thresholding sharpness and value.
PeakDetect
PeakDetect[list]
gives a binary list in which 1s correspond to peak positions in list.
PeakDetect[list,σ]
detects peaks that survive Gaussian blurring up to scale σ.
PeakDetect[list,σ,s]
detects peaks with minimum sharpness s.
PeakDetect[list,σ,s,t]
detects only peaks with values greater than t.
PeakDetect[list,σ,{s,σs},{t,σt}]
uses different scales for thresholding sharpness and value.
Details and Options
- PeakDetect finds local maxima using the given constraints.
- PeakDetect[list] automatically chooses constraints to return a set of peaks.
- Input list can be of one of the following forms:
-
{y1,y2,…} a list of values TimeSeries[…] regularly sampled time series object EventSeries[…] regularly sampled event series object - PeakDetect[list,0,0,-∞] returns all the peaks.
- PeakDetect[list,σ,s,t] is equivalent to PeakDetect[list,σ,{s,σ},{t,0}].
- PeakDetect takes a Padding option. By default, Padding->"Reflected" is used.
Examples
open all close allBasic Examples (1)
Scope (12)
Data (4)
list = {1, 3, 5, 6, 6, 4, 3, 2, 4, 7, 3, 2, 4, 2, 2};ListPlot[{list, list PeakDetect[list]}, Joined -> {True, False}, Filling -> {2 -> 0}, FillingStyle -> Opacity[1]]Peaks of a TimeSeries object:
ts = TemporalData[TimeSeries, {{{54.75, 54.09, 53.89, 55.86, 55.9, 55.63, 53.63, 53.46, 54.15, 57.9,
56.9, 56.63, 56.2, 57.04, 58.32, 57.63, 59.21, 61.06, 62.48, 63.5, 62.74, 62.52, 64.4, 64.96,
64.06, 64.87, 67.06, 69.04, 68.12, 72.64, 73.5, ... 75.04,
75.59, 76.79, 76.86, 77.28, 78.76, 79.4, 79.81, 80.63, 80.88, 81.04, 81.15}},
{TemporalData`DateSpecification[{2013, 1, 2, 0, 0, 0.}, {2013, 11, 27, 0, 0, 0}, {1, "Week"}]},
1, {"Discrete", 1}, {"Discrete", 1}, 1, {}}, True, 10.];peaks = PeakDetect[ts, 0, 0, 0]ps = TimeSeries[ts["Values"] peaks["Values"], {ts["Times"]}];DateListPlot[{ts, ps}, Filling -> {2 -> 0}, Joined -> {True, False}]Peaks of an EventSeries object:
v = RandomInteger[{-10, 10}, n = 500];
t = Range[n] / N[n];es = EventSeries[v, {t}]peaks = PeakDetect[es, 1, 0, 0]ps = TimeSeriesThread[#[[1]] * #[[2]]&, {es, peaks}]ListPlot[es, Filling -> {1 -> Axis}, Epilog -> {PointSize[.02], Orange, Point[ps["Path"]]}]Peaks of a list of Quantity objects:
data = {Quantity[9, "Feet"], Quantity[86, "Inches"], Quantity[27, "Meters"], Quantity[79, "Feet"], Quantity[90, "Feet"], Quantity[41, "Inches"], Quantity[99, "Inches"], Quantity[6, "Feet"], Quantity[38, "Feet"], Quantity[89, "Feet"], Quantity[53, "Feet"], Quantity[85, "Meters"], Quantity[92, "Meters"], Quantity[95, "Meters"], Quantity[49, "Feet"]};peaks = PeakDetect[data]ListPlot[{data, data peaks}, Joined -> {True, False}, PlotStyle -> {Automatic, Orange}]Threshold for values greater than 30 meters:
peaks30 = PeakDetect[data, Automatic, Automatic, Quantity[30, "Meters"]]ListPlot[{data, data peaks30}, Joined -> {True, False}, PlotStyle -> {Automatic, Orange}, PlotRange -> All]Parameters (8)
By default, an automatic scale is used:
v = {2, 1, 6, 5, 7, 4};
PeakDetect[v]v = {2, 1, 6, 5, 7, 4};
PeakDetect[v, 0]Compute peaks at different scales:
list = Table[ Sin[x] + RandomReal[.5{-1, 1}], {x, 0, 3 Pi, 0.1}];
ListLinePlot[list]Table[ListPlot[{list, list PeakDetect[list, σ]}, Joined -> {True, False}, PlotStyle -> {Automatic, Red}, Axes -> {True, False}], {σ, {1, 2, 4}}]When finding peaks at scale
, only peaks that sustain a blur up to scale
are returned:
values = {2, 1, 3, 5, 6, 6, 4, 3, 2, 4, 7, 3, 4, 2, 2, 1};peaks = PeakDetect[values, 1]Signal and its blurred version at scale
:
ListLinePlot[
{values, GaussianFilter[values, {3, 1}], values peaks},
PlotStyle -> {Medium, Dashed, Red}, Joined -> {True, True, False}, Filling -> {3 -> 0}, PlotLegends -> {"original", "smoothed", "peaks"}
]By default, peaks are not filtered based on their sharpness, equivalent to
:
v = {2, 1, 3, 5, 6, 6, 4, 3, 2, 3, 7, 2, 3, 4, 3, 2};PeakDetect[v, 0, 0]Specify minimum sharpness value
:
v = {2, 1, 3, 5, 6, 6, 4, 3, 2, 3, 7, 2, 3, 4, 3, 2};p = PeakDetect[v, 0, 3]Sharpness, defined by the negative second derivative, should be greater than the specified
:
ListLinePlot[
{v, ListConvolve[{1, -2, 1}, ArrayPad[v, 1, "Reversed"]], v p},
Joined -> {True, True, False}, PlotStyle -> {Automatic, Dashed, {Red, PointSize[0.03]}}, PlotRange -> All, Epilog -> {Dashed, Red, Line[{{0, -3}, {16, -3}}]}]Specify a minimum height value
:
list = {2, 1, 3, 5, 6, 6, 4, 3, 2, 4, 7, 1, 4, 2, 2, 1};peaks = PeakDetect[list, 0, 0, 5.1]ListPlot[{list, list peaks}, Joined -> {True, False}, PlotStyle -> {Automatic, {Red, PointSize[0.04]}}, Epilog -> Line[{{0, 5.1}, {20, 5.1}}]]Apply the value threshold after smoothing the data using a scale
:
list = {2, 1, 3, 5, 6, 6, 4, 3, 2, 4, 7, 1, 4, 2, 2, 1};peaks = PeakDetect[list, 2, 0, {5.1, 1}]ListPlot[{list, GaussianFilter[list, 1{3, 1}], list peaks}, Joined -> {True, True, False}, PlotStyle -> {Automatic, Dashed, {Red, PointSize[0.04]}}, Epilog -> Line[{{0, 5.1}, {20, 5.1}}]]Options (1)
Padding (1)
By default, Padding->"Reflected" is used:
values = {2, 1, 3, 5, 6, 6, 4, 3, 2, 4, 7, 3, 4, 2, 2, 1};peaks = PeakDetect[values, 0]ListPlot[{values, values peaks}, Joined -> {True, False}, Filling -> {2 -> 0}, FillingStyle -> Opacity[1]]peaks2 = PeakDetect[values, 0, Padding -> 4]ListPlot[{values, values peaks2}, Joined -> {True, False}, Filling -> {2 -> 0}, FillingStyle -> Opacity[1]]Applications (3)
Find peaks of the recent sunspot activity:
data = WolframAlpha["sun spot", {{"SunspotsPartialTimeSeries:SpaceWeatherData", 1}, "TimeSeriesData"}][[All, 2]];ListLinePlot[data, PlotRange -> {10, All}]peaks = PeakDetect[data, 5, 0, 0];Total[peaks]ListLinePlot[data, Epilog -> {PointSize[Medium], Orange, Point[Transpose[{Range[Length[data]], data peaks}]]}, PlotRange -> {10, All}]Peaks in a discrete-time Fourier transform:
a = LeastSquaresFilterKernel[{"Hilbert", 3}, 32];
data = Table[Abs@ListFourierSequenceTransform[a, x], {x, 0, π, .01}];
ListLinePlot[{data, data PeakDetect[data]}, PlotRange -> All]Mean daily temperatures for Chicago during a period of two months:
temp = WeatherData["Chicago", "MeanTemperature", {{2014, 11, 1}, {2014, 12, 31}, "Day"}]DateListPlot[temp]Find peaks in the temperature:
peaks = PeakDetect[QuantityMagnitude /@ temp["Values"], 0, 0, 0];Create a new time series with peaks stored using MetaInformation:
res = TimeSeries[temp, MetaInformation -> {"Events" -> EventSeries[QuantityMagnitude /@ (peaks * temp["Values"]), {temp["Dates"]}]}]Plot the mean temperatures with warmer days marked:
DateListPlot[res, Epilog -> {PointSize[Medium], Point[Select[res["Events"]["Path"], (#[[2]] != 0)&]]}]Possible Issues (1)
Symmetric twin peaks that merge under Gaussian blurring may survive as peaks:
data = {0, 0, 0, 0, 3, 7, 9, 8, 6, 5, 6, 8, 9, 7, 3, 0, 0, 0, 0};gdata = GaussianFilter[data, 3{3, 1}, Padding -> "Fixed"];ListLinePlot[{data, gdata}]peaks = PeakDetect[data, 3, Padding -> "Fixed"]ListPlot[{data, gdata, data peaks}, Joined -> {True, True, False}, Filling -> {3 -> 0}, FillingStyle -> Opacity[1]]Related Guides
Text
Wolfram Research (2014), PeakDetect, Wolfram Language function, https://reference.wolfram.com/language/ref/PeakDetect.html (updated 2021).
CMS
Wolfram Language. 2014. "PeakDetect." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/PeakDetect.html.
APA
Wolfram Language. (2014). PeakDetect. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PeakDetect.html
BibTeX
@misc{reference.wolfram_2026_peakdetect, author="Wolfram Research", title="{PeakDetect}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/PeakDetect.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_peakdetect, organization={Wolfram Research}, title={PeakDetect}, year={2021}, url={https://reference.wolfram.com/language/ref/PeakDetect.html}, note=[Accessed: 13-June-2026]}