Page 1 of 1

how to check for nan values

Posted: Fri Oct 12, 2007 5:32 am
by zerostar07
Is there some way to programmatically detect the error when neuron variables go out of bounds? or some way to check if a stored value is NaN? I am running batch jobs of neuron and need a way to disregard bad results. thanks

error detection

Posted: Thu Dec 13, 2007 9:20 am
by zerostar07
Is there a way to check for runtime errors/infinite values? Will neuron exit with an error code? Can somebody give me a hint on this please?

Posted: Thu Dec 13, 2007 12:59 pm
by ted
An ounce of prevention is worth a pound of cure. Examine your code and revise as
necessary to deal with unreasonably large exponents or divide by zero errors. "Usual
suspects" include HH-style ionic conductances whose rate constants are specified by
functions that become 0/0 at half-activation points (easily dealt with via Lhospital's rule).

If you believe that NEURON is generating such errors "internally"--i.e. they aren't
"programmed into" your code--please let us know so we can look for bugs or try to devise
strategies for preventing such occurrences.

Re: Detecting nan and other errors under program control

Posted: Tue Oct 07, 2008 1:15 am
by wvangeit
So is there a way in the hoc language to see if e.g. soma.v(0.5) is not "nan" ?
I need this, because I'm doing parameter searching, and apparently some parameter sets generate results with "nan", in which case I need to detect this.

Thank you,

Werner Van Geit

Re: Detecting nan and other errors under program control

Posted: Tue Oct 07, 2008 10:17 am
by hines
You can compare numbers as strings. Consider
oc>for (a=1; strcmp(s, "inf") != 0; a *= 2) { sprint(s, "%g", a) print a }
The last two things it prints on my machine are:
8.9884657e+307
inf