getmin: Approximates the minimum of a function given on a grid

Description Usage Arguments Value Note Author(s) Examples

View source: R/getmin.R

Description

Approximates the minimum of a function given on a grid. Quadratic approximation around the point where the mimimal function value is observed is used (if that point is in the interior).

Usage

1
getmin(x, y, which="global", count.minima=FALSE, verbose=TRUE)

Arguments

x

Vector with the x-values at which the function is observed. Should be sorted.

y

Vector with the function values.

which

Defines which miminum we want to find. Possible values are "global" for the global minimum, "left" for the left-most local minimum and "right" for the right-most local minimum. Abbreviations ("g", "r", "gl", etc.) may be used.

count.minima

If TRUE, the number of local minima in the observed function values is returned.

verbose

If TRUE, the routine will give a warning if any exceptions occur.

Value

A list with the following elements is returned:

xmin

The x-coordinate of the minimum.

ymin

The approximate value of the function at the minimum.

nmin

The number of local minima in the y-vector (if requested, otherwise 0).

excep

Indicates whether an exeption has occurred: -1 if the minimum was found at the left end, 1 if the minimum was found at the right end, 5 if the minimum was in the middle but the quadratic fit yielded a location of the minimum which was outside of the interval defined by the three points used for the quadratic fit and 0 in all other cases.

Note

The vector x must be sorted.

Author(s)

Berwin A Turlach Berwin.Turlach@gmail.com

Examples

1
2
3
        x <- -100:100/50
        y <- x*x
        getmin(x,y)

DeconWK documentation built on May 2, 2019, 6:08 p.m.