bisect: bisect - a generic bisection function

View source: R/bisect.R

bisectR Documentation

bisect - a generic bisection function

Description

provides recursive bisection algorithm for an arbitrary function It evaluates the function foo at the bounds and replaces one of the boundaries until a maximum is found or the interval becomes too small

Usage

bisect(foo, bounds, known = NULL, ..., tolx = 5, toly = 0.01)

Arguments

foo

a function mapping a one-dim argument to one-dim value

bounds

a vector of length 2 with real valued numbers (i.e. two arguments of foo)

known

tells for which of the arguments a value is known (defaults to NULL)

...

additional parameters for foo

tolx

break condition for argument (defaults to 10)

toly

break condition for value (defaults to 0.01)

Value

A range of bounds where foo is maximal.

Examples

    get_maximum <- bisect(function(x){-(x-2)^2}, c(-5,50))


theislab/kBET documentation built on Jan. 27, 2024, 9:58 p.m.