If I run the function multiple times it gives the error "non-finite value supplied by \'nlm\'". I have to run the code 500 times. Is there any way I can deal with the