3 ms·
> but what you really should be looking at is the relative error This actually depends on the specific problem you're talking about, and there's also the issue
by qsort 6y ago
> but what you really should be looking at is the relative error
This actually depends on the specific problem you're talking about, and there's also the issue of forward vs. backward error. Unless you're doing something that requires additional care, unit-testing against abs(expected - actual) < 0.001 is relatively safe (and if you are, then God help you).
100% agree on the rest of the comment, requiring numerical methods to converge to a specific IEEE 754 double precision floating point is just dumb.
- jcranmer 6y ago1e-3 is a pretty loose error bound if you're dealing with double-precision. I usually use tolerances in the region of 1e-5 to 1e-10.
- nitrogen 6y agoIt's also better to use significant figures or a relative (as opposed to absolute as computed above) error if you're working with small values.
- Tainnor 6y agoI'm not very experienced with this in practice and can mostly only speak to what I was taught in numerical methods, but it was my understanding that a) relative errors don't arbitrarily depend on your units and b) they seem to be better behaved in theory, or at least, it's how algorithms are typically analysed - e.g. if you multiply two numbers that both have some associated error, the relative error is the sum of the individual relative errors (plus quadratic terms which you would ignore).