Question: How To Determine The Location Of A Peak In A List Of Numbers
0
7.5 years ago by
litiancheng.gansu10 wrote:

hello all, I have some numbers, these numbers can be plot and we can found there is a peak, at first this ploted line was increasing, then decreasing, I want to get the peak point among these number, but this line is not absolute increasing and decreasing, there are some small "up" and "drop", it's a sawtooth line. Is there is a R package or perl module would be great helpful to me, could somebody help me?

for example, these number:

`1, 2 ,4, 3, 5, 7, 5, 8, 10, 9, 7, 8, 5, 6, 4, 2, 3, 1`

I want to get "10".

Add: there are not only one peak, sometimes two or more peak, such as:

``````1, 2 ,4, 3, 5, 7, 5, 8, 10, 9, 7, 8, 5, 6, 4, 2, 3, 1, 0, 0, 0, 0, 0, 2, 4, 3, 5, 8, 7, 6, 2, 3, 1
``````

I want to get 10 and 8

perl R statistics • 1.8k views
modified 3.3 years ago by Biostar ♦♦ 20 • written 7.5 years ago by litiancheng.gansu10
2
7.5 years ago by
Istvan Albert ♦♦ 84k
University Park, USA
Istvan Albert ♦♦ 84k wrote:

The concept of a "peak" is a lot more complicated than that.

First and foremost it requires a careful definition of what you wish to call a peak - peaks are easy to see by eye while forgetting that our brains have awesome pattern matching capabilities and what we can easily see as a peak may be more difficult to describe in an algorithmic fashion.

What is easy to define is the concept of local maxima: a value that has smaller values on both of its sides. If that fits your purpose then the code is near trivial. More likely however it does not. In that case the simplest approach is to apply a data smoothing process - and then again look for local maxima. Your peak prediction then becomes a choice of data smoothing.

1
7.5 years ago by
Alex Reynolds30k
Seattle, WA USA
Alex Reynolds30k wrote:

Within R:

``````> v <- c(1, 2 ,4, 3, 5, 7, 5, 8, 10, 9, 7, 8, 5, 6, 4, 2, 3, 1)
> max(v)
[1] 10
``````