Re: Two implementations of simple math equation yield different
by Victor Bazarov <v.Abazarov@[EMAIL PROTECTED]
>
May 13, 2008 at 01:25 PM
Avi wrote:
> One way to identify and ignore small differences is to set a small
> threshold, say:
> double epsilon = 1E-6
> and compare the difference against the threshold as follows:
>
> if (abs(diff) < epsilon)
> {
> // difference is considered as noise
> }
> {
> // difference is significant
> }
>
> [..]
> Is there a systematic threshold that can be used to define when the
> differences are noise and when they are significant?
> Or should I just pick a number which is small enough in my mind (say
> epsilon = 1 E-6)?
It depends on your problem domain. Some compare absolute differences
(like you're suggesting here) and are happy. Some make the diff value
relative to the range (by dividing the diff by the larger of the two
values). If all the numbers are from the same range you're going to
be fine if you just pick the value that "fits" your range. The value
of the numeric epsilon only relates to the range from 0 to 1, IIRC.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask