pythonlistpython-2.7numpy

What is the difference between rtol and atol in allclose()?


What is the difference between relative tolerance (rtol) and absolute tolerance (atol) in allclose().

Somebody please explain the meaning of the following:

np.allclose(center_var,center_a,rtol=1e-02, atol=1e-03)

Solution

  • They are used differently in the formula as you can read here:

    If the following equation is element-wise True, then allclose returns True.

    absolute(a - b) <= (atol + rtol * absolute(b))

    The above equation is not symmetric in a and b, so that allclose(a, b) might be different from allclose(b, a) in some rare cases.