Skip to contents

find_local_optima returns the local optima of histograms

Usage

find_local_optima(x, threshold = 0, flat_endpoints = T)

Arguments

x

numeric vector representing the density of a histogram

threshold

threshold for local optima, i.e. a point can only be considered a local optima if it differs from its neighbour optima by greater than the permitted threshold, default 0

flat_endpoints

in regions of flat density, whether to return the endpoints or the midpoints

Value

a list of two vectors

min_ind

indices of local minima

max_ind

indices of local maxima

Examples

if (FALSE) {
x <- c(1,2,3,2,1,2,3,2,1)
find_local_optima(x)
}