[Numpy-discussion] numerical noise for simple calcululations
Sun Feb 10 12:18:07 CST 2008
On Sun, Feb 10, 2008 at 4:23 AM, dmitrey <email@example.com> wrote:
> hi all,
> I need a good estimation of noise value for simple calculations.
> I.e. when I calculate something like sin(15)+cos(80) I get a solution
> with precision, for example, 1e-11.
> I guess the precision depends on system arch, isn't it?
> So what's the best way to estimate the value?
> I guess here should be something like 10*numpy.machine_precision, isn't
This is a complicated subject, which I'm really not qualified to comment on,
but I'm not going to let that stop me. I believe that you want to know how
accurate something like the above is given exact inputs. That is a somewhat
artificial problem, but I'll answer it to the best of my ability.
Functions like sin, cos, +, etc can in theory compute there result to within
on ULP, or maybe half an ULP (I can't recall exactly). An ULP is a Unit in
the Last Place. To explain an ULP, let's pretend that we were using decimal
floating point with 3 digits of precision and look at a couple of numbers:
1.03e-03 --> 1 ULP = 1e-5
3.05e+02 --> 1 ULP = 1
We're obviously not using decimal floating point, we're using binary
floating point, but the basic idea is the same. The result is that the
accuracy is going to totally depend on the magnitude of the result. If the
result is small, in general the result will be more accurate in an absolute
sense, although not generally in a relative sense.
In practice, this is drastically oversimplified since the inputs are
generally of finite accuracy. Different functions will either magnify or
shrink the input error depending on both the function and the value of the
input. If you can find an easy to read introduction to numerical analysis,
it would probably help. Unfortunately, I don't know of a good one to
recommend; the text I have is a pretty hard slog.
To complicate this further, functions don't always compute there results to
maximum theoretical accuracy; presumably in the interest of reasonable
So, in the end the answer is; it depends. In practice the only useful,
simple advice I've seen to get a handle on accuracy is to compute results
using at least two different precisions and verify that things are
converging sensibly. And compare to known results wherever possible.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion