So you are confirming what I discovered to myself.
I expected tolerance to be uniform in space,
or at least not singular at zero.
(Thinking of it as a _identity radius_, 
being within which two points are equal).
As it turns out, the identity radius is proportional 
to the (max) magnitude of the points. It is the same 
as tolerance t in the vicinity of 1:

   1=1+2^_44
1
   1=1+2^_43
0

And identity radius grows with the magnitude

   (2^32)=(2^32)+2^_44+32
1
   (2^32)=(2^32)+2^_44+33
0
   (2^32),2^_44+32          NB. point and radius
4.29497e9 0.000244141

In zero the radius converges to 0, thus no tolerance.

   (2^_1024)=(2^_1024)+2^_44-1024
1
   (2^_1024)=(2^_1024)+2^_44-1023
0
   (2^_1024) , 2^_44-1024   NB. point and radius
5.56268e_309 3.16202e_322

In other words, as we move closer to 0, the
radius shrinks and never reaches to include 0
(unless t >: 1).

Such tolerance model becomes an issue if the domain 
is in the region that includes 0, for examples -3..3.
Typical application, is when we do calculations
with errors, of course, and we still want to identify
the same points.

To make it work, we can transform the domain to
for example, [-6..-3) U [3,6]:

   (1:[EMAIL PROTECTED](*@|) * 3 + |) 1 _1 0 1j_1 3j_3 3
4 _4 3 3.12132j_3.12132 5.12132j_5.12132 6

So how would such nicer comparator look like?

   eq=: 1 : '|@- <:!.0 m * >.&|'
   tr=: 1 : '1:[EMAIL PROTECTED](*@|) * m + |'
   eqt=: 2 : '(m eq)&:(n tr)'

   0 (0.001 eqt 1) 0+0.001
1
   0 (0.001 eqt 1) 0+0.002
0
   0 (0.001 eqt 3) 0+0.001*3
1
   0 (0.001 eqt 3) 0+0.002*3
0


--- Roger Hui <[EMAIL PROTECTED]> wrote:

> It is a direct consequence of the definition of tolerant
> equality that comparisons with 0 are not tolerant:
> 
> x=!.t y if (|x-y)<:t*x>.&|y   definition of tolerant =
> 0=!.t y if (|0-y)<:t*0>.&|y   substitute 0 for x
> 0=!.t y if (|y)<:t*|y         algebra
> 
> So if t<1 (which t is required to be), y must be 0.
> 
> See also the essay in the J Wiki:
> http://www.jsoftware.com/jwiki/Essays/Tolerant_Comparison
> which among other things demonstrates that t>:1 gives
> nonsense results.
> 
> 
> 
> ----- Original Message ----- 
> From: "Oleg Kobchenko" <[EMAIL PROTECTED]>
> To: "Programming forum" <[email protected]>
> Sent: Sunday, May 28, 2006 10:08 PM
> Subject: [Jprogramming] Equal tolerance fit conjunction -- again
> 
> I need to compare floats (complex) with more lenient
> tolerance, that is numbers a bit farther apart would
> return equal. 
> 
> In particular, I need to compare with 0, so that
> for 0e_11 it returns 1 and for 0e_9 it returns 0.
> 
> >From the dictionary,
>   http://www.jsoftware.com/books/help/dictionary/d000.htm
> "comparison is made with a tolerance t , normally 2 to 
> the power _44". But
> 
>    0 = 2^_44
> 0
>    0 = 2^_60
> 0
>    0 = 2^_20
> 0
> 
> So how does this example relate to the rule above?
> 
> It continues, "but also controlled by the fit conjunction !. , 
> as in x=!.0 y . Formally, x=y is 1 if the magnitude of x-y does 
> not exceed t times the larger of the magnitudes of x and y ."
> 
> With zero and positive x we have
> 
>    (|x-0) <: t*x
>    x <: t*x
>    1 <: t
> 
> This doesn't make sense. Can I compare tolerantly
> with zero at all?


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to