Skip to contents

Find values corresponding to extrema of a distribution (numeric vector). First, the function establishes the density of the input numeric vector. Then, it estimates the first derivate. Then, it identifies extrema thanks to the sign changes in derivates. If you want all extrema, minima or maxima, it outputs values.

Usage

find_extrema_density(val, n = 2^10, what = "minima")

Arguments

val

NUMERIC : a numeric vector

n

NUMERIC : a power of 2 to compute the density of val. Low values will decrease confidency in results. High values makes the analysis time consuming (default to 2^10)

what

CHARACTER : one of "minima", "maxima" or "both", to output what you want. If you specify something else, it will returns both minima and maxima (default to "minima")

Value

This function returns a vector of estimated extrema. If "both" is chosen, it outputs a list with names "minima" and "maxima".