[Numpy-discussion] Numpy float precision vs Python list float issue
Charles R Harris
Mon Apr 20 11:03:39 CDT 2009
On Mon, Apr 20, 2009 at 9:49 AM, Rob Clewley <firstname.lastname@example.org> wrote:
> On Mon, Apr 20, 2009 at 10:48 AM, David Cournapeau
> <email@example.com> wrote:
> > Rob Clewley wrote:
> >> David,
> >> I'm confused about your reply. I don't think Ruben was only asking why
> >> you'd ever get non-zero error after the forward and inverse transform,
> >> but why his implementation using lists gives zero error but using
> >> arrays he gets something of order 1e-15.
> > That's more likely just an accident. Forward + inverse = id is the
> > surprising thing, actually. In any numerical package, if you do
> > ifft(fft(a)), you will not recover a exactly for any non trivial size.
> > For example, with floating point numbers, the order in which you do
> > operations matters, so:
> <SNIP ARITHMETIC>
> > Will give you different values for d and c, even if you "on paper",
> > those are exactly the same. For those reasons, it is virtually
> > impossible to have exactly the same values for two different
> > implementations of the same algorithm. As long as the difference is
> > small (if the reconstruction error falls in the 1e-15 range, it is
> > mostly likely the case), it should not matter,
> I understand the numerical mathematics behind this very well but my
> point is that his two algorithms appear to be identical (same
> operations, same order), he simply uses lists in one and arrays in the
> other. It's not like he used vectorization or other array-related
> operations - he uses for loops in both cases. Of course I agree that
> 1e-15 error should be acceptable, but that's not the point. I think
> there is legitimate curiosity in wondering why there is any difference
> between using the two data types in exactly the same algorithm.
Well, without an example it is hard to tell. Maybe the print formats are
different precisions and the list values are just getting rounded.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion