Detecting nan and other errors under program control

Anything that doesn't fit elsewhere.
Post Reply
zerostar07
Posts: 6
Joined: Wed Sep 26, 2007 4:42 pm

how to check for nan values

Post 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
zerostar07
Posts: 6
Joined: Wed Sep 26, 2007 4:42 pm

error detection

Post 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?
ted
Site Admin
Posts: 6384
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post 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.
wvangeit
Posts: 21
Joined: Wed Jun 11, 2008 2:14 am

Re: Detecting nan and other errors under program control

Post 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
hines
Site Admin
Posts: 1710
Joined: Wed May 18, 2005 3:32 pm

Re: Detecting nan and other errors under program control

Post 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
Post Reply