[Numpy-discussion] commutative allclose
Charles R Harris
Thu Apr 10 16:49:46 CDT 2008
On Thu, Apr 10, 2008 at 1:56 PM, Tom Johnson <email@example.com> wrote:
> Should allclose() be commutative, so as to prevent the following:
> >>> x = 1.00001001
> >>> allclose(x,1), allclose(1,x)
> (False, True)
> There is some discussion here which provides two possible solutions:
> Notice, the discussion states that their solutions are not
> transitive---nevertheless, I think commutativity is a worthwhile
> improvement. Also, they mention that rtol * abs(y) can cause
> underflow issues. Thus, they implement,
> |x-y|/|y| <= rtol AND(OR) |x-y|/|x| <= rtol
> without an atol option, rather than
> |x-y| <= atol + rtol* |y|
> Naively, it seems like atol is attempting to correct this very issue.
> So do we really need atol?
I think it useful, especially when working with values that may be zero.
However, it might not be necessary in the allclose context. On the other
point, it is also possible to use the max, avg, or sum of |x| and |y|, which
will avoid the case when on of them gets too small.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion