On Thu, Apr 10, 2008 at 1:56 PM, Tom Johnson <[EMAIL PROTECTED]> 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: > > > http://www.boost.org/doc/libs/1_35_0/libs/test/doc/components/test_tools/floating_point_comparison.html > > 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. Chuck
_______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
