# Finding all the local minima from a noisy data plot [duplicate]

I have a data with noisy data which has lot of minimas. One such data file is shown here. What I have been trying to do is the following,

(1) I would to find all the minimas with respect to the common reference bar.

(2) then I have to find the distance between those minimas

(3) and make a histogram.

(2) ,(3) can be done if I could identify all the minimas. I tried couple of methods ,but did not get work here.

• This, this, and FindPeaks and PeakDetect might be helpful. – corey979 Sep 12 '16 at 22:47
• This question is basically a duplicate of "Finding Local Minima / Maxima in Noisy Data", so I vote to close. For example, see the results over the question data of my solution in the referenced discussion. – Anton Antonov Sep 12 '16 at 23:14
• Mr Anton, Did you put a reference bar or something, You see I only want minima w.r.t reference bar not everything – TM90 Sep 12 '16 at 23:48
• @TM90 You have not defined the bar in the question. If you do, selecting the local extrema outside of it is trivial. – Anton Antonov Sep 13 '16 at 0:05
• yeah sure, I guess that will do. Thanks Mr Anton – TM90 Sep 13 '16 at 2:58

## 1 Answer

Try:

minima = TakeSmallestBy[#[[2]] &, 1] /@
Split[
Pick[data, MinDetect[data[[All, 2]], 0.001], 1],
#1[[1]] + 0.002 == #2[[1]] &
]
ListPlot[minima, PlotRange -> All]
Differences@Flatten[minima, 1][[All, 1]]


I used the threshold 0.001 to define the "reference bar." I also used the fact that the x-values in the data set were all exactly 0.002 apart to separate distinct minima.

MinDetect forms the basis of this approach. The rest is just list manipulation to isolate the minima and the associated x-values for finding distances.

• Thanks a lot Mr Josh Bishop, it does work. – TM90 Sep 13 '16 at 4:25
• Good solution. (+1) – Anton Antonov Sep 13 '16 at 13:26