Skip to content
Advertisement

comparing numpy arrays with tolerance

I’m trying to compare floating numbers that are stored in numpy arrays. I would like them to be compared with a tolerance and every number of the array should be compared with every number of the other array. My attempt is shown underneath, I used two simple arrays as examples but it has the problem that it only compares numbers with the same indices.

JavaScript

It would be great if anyone could help me.

Thank you.

Advertisement

Answer

Use np.isclose with atol = abs_tol.

JavaScript

To get the observed masses:

JavaScript

Result

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement