How To Determine The Location Of A Peak In A List Of Numbers
2
0
Entering edit mode
11.4 years ago

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

statistics perl r • 2.5k views
ADD COMMENT
2
Entering edit mode
11.4 years ago

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.

ADD COMMENT
1
Entering edit mode
11.4 years ago

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
ADD COMMENT
0
Entering edit mode

thanks, I found I had described the issue incompletely, there are two or more peaks in my data.

ADD REPLY

Login before adding your answer.

Traffic: 1897 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6