In Julia: Is there a way to check equality like R all.equal ()?

Take this R example:

 > x = 0.5 - 0.3 > y = 0.3 - 0.1 > x == y # although mathematically TRUE, it's FALSE for limited precision [1] FALSE > all.equal(x,y) # equal up to precision of computer [1] TRUE 

For a quote from the R documentation:

'all.equal (x, y) is a utility for comparing R objects of' x and 'y testing' for close equality. If they are different, the comparison is still brought to some extent and the difference report is returned. Do not use 'all.equal directly, "if the expressions are either to use 'isTRUE (all.equal (....)), or" are identical if necessary.

In Julia , x == y will return false . Is there any way to verify this equality to the accuracy of the machine in Julia?

+5
source share
1 answer

isapprox(x,y) is what you are looking for.

use ?isapprox in REPL for more help. In particular, there are 2 parameters that indicate the relative tolerance for error and the absolute tolerance for error.

Happy 2016

+5
source

Source: https://habr.com/ru/post/1239617/


All Articles