[R] convergence

Alberto Monteiro albmont at centroin.com.br
Thu Apr 19 15:24:25 CEST 2007


Ted Harding wrote:
> 
> There are various ways round this, but a 'for' loop with
> a fixed number of iterations is not usully one of them!
> 
> The simplest is to use while(). A possibly strategy is
> 
>   Y.old <- initial.Y
>   while(TRUE){
>     Y <- compute.Y(Y.old, ...)
>     if(abs(Y - Y.old) < small.number) break
>     Y.old <- Y
>   }
> 
> This will loop indefinitely until the convergence criterion
> 
>   abs(Y - Y.old) < small.number
> 
> is met, and then stop.
> 
I guess some precaution must be taken to prevent that the loop
runs forever.

Those algorithms that must optimize something, but run the risk 
of running forever, sound like the "chess playing" engine: we
know that a deterministic solution exists (there is a finite number
of chess positions), but it's not practical to check all of them.

I read somewhere that computer loop problems are treated as if
the computer was "playing chess" agains Murphy: it tries hard to
solve the problem, but sometimes he must give up a path and backtrack
to a less optimum but faster solution.

Do I make any sense?

Alberto Monteiro



More information about the R-help mailing list