No. ---------------------------------------------------------------------------- -------
Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html ---------------------------------------------------------------------------- -------- -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alberto Monteiro Sent: Thursday, April 19, 2007 9:24 AM To: [EMAIL PROTECTED]; r-help@stat.math.ethz.ch Subject: Re: [R] convergence 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. ______________________________________________ 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.