Output turn to NaNs and back to values in running the same code multiple times

Hello, 

I am facing an interesting situation. I am running a function that I wrote. I am making no changes to the function or its arguments. Simply running it over and over to test for consistency in output. 

I am noticing that sometimes, the function returns the output variable as NaNs, and during other trials it returns the value that it is supposed to return. The output variable is calculated based on some very small values on the order of 1e-8 and 1e-9 etc. 

I am trying to understand what is causing this instability/lack of consistency in output and how can I get rid of it. 

Kindly advise. 

Thanks a ton, 

Peeyush

 

In case you haven't, use the debugger and observe when variables or wave contents turn NaN. Then you know where it happens and you can investigate further. Maybe not the cause but make sure your waves are defined as double precision, i.e. use Make/D.

This sounds very strange. If the function receives exactly the same input then the output should also be the same unless you have a randomizer in there (time of day, noise etc.). If you provide a minimal example we can have a look.

If you pass parameters by reference (including waves), or use NVAR or SVAR in your function, make sure that the parameters are not changed by your function.

DisplayHelpTopic "How Parameters Work"