convergence: Change convergence criterion in fixed point iteration

Description Usage Arguments Value Author(s) Examples

Description

A fixed point is defined by f(x)=x. Often this condition can't be fulfilled exactly, and so we must check convergence using a looser criterion, like abs(f(x)-x) < tol. The convergence criterion can be specified using a function of two arguments: d(x,x'), returning either a logical value or a positive scalar, to be checked against the tolerance 'tol'. The predefined convergence functions are: mse=function(a,b) mean((a-b)^2) rmse=function(a,b) sqrt(mean((a-b)^2)) mad=function(a,b) mean(abs(a-b)) mre=function(a,b) mean(abs(a-b)/abs(a+b) If convergence can't be reached at all, we interrupt the search after a maximum number of iterations (set by maxIter).

Usage

1
convergence(fun, tol, maxIter)

Arguments

fun

convergence check: either a function with two arguments or a character string like "rmse"

tol

tolerance

maxIter

Value

used for side effects

Author(s)

Simon Barthelme

Examples

1
2
3
4
5
6
7
8
f <- function(x) x/2
g <- fp(f)
g(3) #by default convergence is assessed using all.equal
(g+convergence("rmse",tol=.1))(3) #root-mean-square less than .1
(g+convergence("rmse",tol=.01))(3) #root-mean-square less than .01
#Custom function
d = function(a,b) sum(abs(log(a)-log(b)))
(g+convergence(d,tol=.01))(3) #can't converge because fixed point is at 0

dahtah/fixedpoints documentation built on May 14, 2019, 3:25 p.m.