аватар question@mail.ru · 01.01.1970 03:00

Finding positive peaks of function

It is necessary to programatically find the number and location of positive peaks on the graph.
It is known that the number of peaks is odd. Typically, 3, 5 or 7. In this case, 3. It is also known that each positive peak follows negative.
How best to solve such a problem on Python? It is advisable without the selection of the
coefficients : the data always begins with a positive peak and end in negative.
Data is a vertical projection of the image treated with the function of np.gradient (projection)/projection . That is, the ratio of the second derivative of the function to its height.

аватар answer@mail.ru · 01.01.1970 03:00

Since just local extremum does not suit, you need to add an exceeding the threshold for rejecting small peaks and artifacts. The threshold can be calculated as samples multiplied by a certain constant corresponding to a confidence interval for mathematical expectation.
In practice, this constant is accepted equal to 2.5

upd
taking into account the additional conditions of the task of the PIC maximum should be considered at the same time From the "top" (the starting point or the first value higher than q ) to "bottom" (the first value below -q
). Threshold q .

  • Put top = 0 .
  • Find the coordinate bottom the first point of the segment [top, n-1] . -q . If there is no such point, go to paragraph 7.
  • Find the maximum coordinate on the segment [top, Bottom-1] . If the value of the maximum is greater than the q , write it in an array of peaks.
  • Find the coordinate top the first point of the segment [Bottom+1, N-1] with the value of the larger q . If there is no such point, go to p. 7.
  • go to paragraph 3.
  • use the peak array.
  • Latest

    Similar