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

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to