View Single Post
Siveroo
Junior Member
Join Date: Apr 2020
Old 10-19-2020 , 05:29   Re: Which method is more efficient?
Reply With Quote #8

Quote:
Originally Posted by HamletEagle View Post
With the first method, it is possible the algorithm will never converge or converge after a really long time(i.e all new generated points are inside the R\C area) which will end up being much slower than the second method. At the very least you should limit the max number of iterations to avoid (nearly) infinite loops. That's a very common practice when dealing with such algorithms.

Something like this:
PHP Code:
new maxIters 500
while(condition && maxIters-- > 0)
{
    
//do something

I should also mention that corectness is always more important than performance. No point in a fast yet flawed algorithm.
yeah , dont worry im aware of that possibility.. and like i said i dont really like the first code even if the chance of it's not converging is really really stupid low. thanks for the response tho, really appreciate it!

EDIT : the chance of the first code doesnt converge after 10 attempts (in percent)


maybe if i wanna use the first code, im going to limit the iteration like 10 times only, and if it still cant find generate the point inside the circle, just going to replace it with the origin , since the occurence of this event happening are somewhat still "random", although i still hate this method..

Last edited by Siveroo; 10-19-2020 at 05:51.
Siveroo is offline