0

I would like to find a specific set of maximum points in a collection of data I create. Visually it looks something like this: Where the blue points are my data, the green line is the plot, and in yellow I have marked which max points I want to find. enter image description here

So far I have tried to "smooth" the function via local average and a rolling window but that modifies the max values and does not quite smooth it out enough to see each of those noisy peaks as one single max value.

Is there some transform I could do in code to this array of number to allow for easier extraction of such values?

I am writing in C#. The closest posts I could find to what I am looking for were for R which I know nothing about unfortunately.

TheFooBarWay
  • 594
  • 1
  • 7
  • 17
  • I guess U need some statistic,u can take a look at here http://www.originlab.com/doc/Origin-Help/DescStatsRow-Dialog – sakir Dec 30 '16 at 15:11
  • I have no knowledge of signal processing, so this is a thoroughly uneducated attempt to break the problem down. Your data appear to be periodic. If you know what period you're expecting or can find the dominant frequency via FFT or something, you could then create a window as wide as the period and move it a period at a time, finding the local max each time. You'd have to do something to make sure you start with a local maximum roughly in the center of your window, to avoid accidentally capturing two peaks. – adv12 Dec 30 '16 at 15:23
  • u can also take alook at here http://stackoverflow.com/questions/13694523/finding-the-local-maxima-peaks-and-minima-valleys-of-histograms or this one http://stackoverflow.com/questions/5269000/finding-local-maxima-over-a-dynamic-range – sakir Dec 30 '16 at 15:57

2 Answers2

2

Really naive but efficient approach w/o a statistics package: If you want to find all local maxima for a continuous function, they correspond with changes in the 'direction' of the function (ascending or descending). Whenever it goes from asc-->desc you have a local maxima.

Something like this: https://dotnetfiddle.net/4YPz2A

This will give you more 'yellow' matches than you want; but you could get to the 'right' amount by smoothing the dataset (for example by averaging every 3 consecutive data points first).

Assaf
  • 1,336
  • 1
  • 10
  • 17
0

You can set a threshold to remove all the points below a certain value. In your case you could keep all the points above 1.2 for example. Once you have those points you can use some clustering technique based on the horizontal distance between points to find each cluster representing a different peak, and then all you have to do is to find the maximum value for each peak.