ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 30 Jul 2012 23:42:58 -0500Dealing with 'NaN' values in listshttp://ask.sagemath.org/question/9195/dealing-with-nan-values-in-lists/ Hello!
Maybe somebody here has an experience on working with 'NaN' values in Sage.
My situation is the following: I need to load some experimentally measured data into a list of float values. But unfortunately, the experimental data set is not "solid" - it has 'NaN' values somewhere inside.
What I currently need to perform first of all is to calculate the average value of a list slice. Preferably, simply using 'mean()' if it is possible.
So could somebody please give me an advice how to work with such arrays correctly?
Thank you.v_2eMon, 30 Jul 2012 23:42:58 -0500http://ask.sagemath.org/question/9195/any way to turn off error msg when I catch the errors?http://ask.sagemath.org/question/7938/any-way-to-turn-off-error-msg-when-i-catch-the-errors/trying to check whether a numerical expression is NaN or not.
My expression is log(arcsin(e)). If I apply N() on the expression it goes into infinite loop. I try to catch the runtime error. Everything seems to work in the following code except the error message displayed. I do not want that message in output. Any way to turn the error message off.
sage: def number(expr):
....: try:
....: n = N(expr)
....: except (RuntimeError):
....: n = N(NaN)
....: return n
....:
sage: expr=log(arcsin(e))
sage: a=number(expr)
Exception RuntimeError: 'maximum recursion depth exceeded in __subclasscheck__' in <type 'exceptions.RuntimeError'> ignored
# I do not want the above error message in output
sage: a
NaN
sage: a.is_NaN()
True
ShuFri, 11 Feb 2011 06:19:00 -0600http://ask.sagemath.org/question/7938/When is 0^0 NaN in Sage?http://ask.sagemath.org/question/7676/when-is-00-nan-in-sage/sage: 1 == 0^0 == 0**0 == pow(0,0) <br>
True <br>
<br>
sage: power_mod(0,0,2) <br>
Traceback (click to the left of this block for traceback) <br>
... <br>
ArithmeticError: 0^0 is undefined. <br>
<hr>
<br>
[http://en.wikipedia.org/wiki/Exponentiation#IEEE\_floating\_point\_standard][1]
[1]: http://en.wikipedia.org/wiki/Exponentiation#IEEE_floating_point_standardccanoncWed, 08 Sep 2010 09:04:29 -0500http://ask.sagemath.org/question/7676/