findPeaks: Find local peaks in a distribution

findPeaksR Documentation

Find local peaks in a distribution

Description

Find local peaks in a distribution

Usage

findPeaks(x, m = 3)

Arguments

x

vector of value series

m

number of adjacent points needed to be lower to count as a peak

Details

use findPeaks(-x) to find troughs

Value

vector of positions in x where there is a peak

Examples

x <- w <- rnorm(n = 100, mean = 0, sd = 1) 
for (t in 2:100) { x[t] <- x[t - 1] + w[t] }
p3 <- findPeaks(x)
p10 <- findPeaks(x, 10)
t10 <- findPeaks(-x, 10)
plot(x, type = "l")
abline(v = p10, col = "green", lwd = 5)
abline(v = p3, col = "blue")
abline(v = t10, col = "red")


johngodlee/JLGMisc documentation built on June 29, 2024, 9:15 p.m.