Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
967 views
in Technique[技术] by (71.8m points)

r - Find sustained peaks using pracma::findpeaks

How can I use findpeaks to look for a sustained peak across 3 consecutive time intervals?

I am using this to look for sustained CPU usage of at least 3 minutes.

findpeaks(MyData$X.busy, threshold=80) ??

    Timestamp, X.busy
    2017-10-08 00:00:00, 10
    2017-10-08 00:01:00, 10
    2017-10-08 00:02:00, 10
    2017-10-08 00:03:00, 10
    2017-10-08 00:04:00, 10
    2017-10-08 00:05:00, 90 <---
    2017-10-08 00:06:00, 90 <---
    2017-10-08 00:07:00, 90 <---
    2017-10-08 00:08:00, 10
    2017-10-08 00:09:00, 10

Any advice is appreciated.

Lou

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Just had the same issue. The documentation is not quite clear on that, but reading the source code of findpeaks helped. A slightly modified version of your case, with one non-sustained peak in position 2:

 y  <- c(10, 11, 10, 10, 10, 90, 90, 90, 10, 10)
 pp <- "[+]{1,}[0]+[-]{1,}"
 findpeaks(y, peakpat=pp)

The key is the [0]+ which means stationary for at least 1. If you wanted to also include the first unsustained peak, you could do use [0]* instead.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...