[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Nearly Equal or is it Fuzzy Math



PureBytes Links

Trading Reference Links

Hello,
 
ulps should not be greater than two millions (this would give ~13% tolerance/sensitivity)

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: Joe Landry
Sent: Friday, January 27, 2006 2:08 PM
Subject: Re: [amibroker] Nearly Equal or is it Fuzzy Math

Tomasz  - Thanks. 
Too often I don't write my own the AlmostEqual is better works as intended in
a Bollinger Band crossing/touching detection.
 
I'm wondering what the upper limit is on ULPs range, the tolerance/sensitivity parameter.
 
Best regards
Joe
 
----- Original Message -----
Sent: Thursday, January 26, 2006 5:00 AM
Subject: Re: [amibroker] Nearly Equal or is it Fuzzy Math

Well, prior to 4.73 you can write your own AlmostEqual :-)
 
for example
 
function AlmostEqualEmu( x, y )
{
   return abs( x - y ) < 0.0001; 
} 
 
Note that this is "weak" emulation - it just checks whenever the differnece is less than 0.0001
and true AlmostEqual is way better because it correctly adopts to magnitude of numbers compared.

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: Bob Jagow
Sent: Thursday, January 26, 2006 11:03 AM
Subject: RE: [amibroker] Nearly Equal or is it Fuzzy Math

Perhaps superior but somewhat late--what would one do prior to 4.73.0?

 

-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]On Behalf Of Tomasz Janeczko
Sent: Thursday, January 26, 2006 1:22 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] Nearly Equal or is it Fuzzy Math

 

AlmostEqual function is superior solution.


Best regards,
Tomasz Janeczko
amibroker.com

----- Original Message -----

From: Bob Jagow

To: amibroker@xxxxxxxxxxxxxxx

Sent: Thursday, January 26, 2006 4:01 AM

Subject: RE: [amibroker] Nearly Equal or is it Fuzzy Math

 

The old saw is to always use >= or <=  with floats.

 

Bob

 

 

-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]On Behalf Of Tomasz Janeczko
Sent: Tuesday, January 24, 2006 8:44 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] Nearly Equal or is it Fuzzy Math

 

AlmostEqual()  - it is in the read me.

 

AlmostEqual( x, y, ulps = 5 )

this is a helper function for comparing floating point numbers.It returns True if x and y are equal or almost equal upto defined accurracy (ulps).It is recommended to use this function instead of equality check (==) as itleads to more reliable comparisons and less headache caused by IEEE floating pointacurracy issues.

Parameters:x, y - the numbers or arrays to be compared,Ulps stands for "units in last place" and represents maximum relative error of the comparison. Since 32 bit IEEE floating point numbers have accurracy of 7 significant digits, 1 unit in last place(ulp) represents relative error of 0.00001 %. The default value of ulps parameter is 5 which gives roughtly 0.00005% "comparison sensitivity".


Example code:

if( 1/3 == 0.3333333 )
{
  printf("32-bit Floating point IEEE exact equality\n");
}

if( AlmostEqual( 1/3, 0.3333333 ) )
{
  printf("Numbers are almost equal\n");
}

 

HINT FOR THE FUTURE:

At any time if you forgot the name, just type space and then press CTRL+SPACE keys in the AFL editor and you will see the list of all keywords.


Best regards,
Tomasz Janeczko
amibroker.com

----- Original Message -----

From: Joe Landry

 

To: amibroker@xxxxxxxxxxxxxxx

Sent: Tuesday, January 24, 2006 2:57 PM

Subject: [amibroker] Nearly Equal or is it Fuzzy Math

 

I thought Tomasz had added a function where one could compare two

numbers and get a TRUE indicator even when the last bit of floating

point number  did not agree. 


I've search the on list of functions and can't seem to find that

function or a discussion out it.

 

Anyone recall what that function is called? 

 

Thanks

Joe  

 

 






Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html





YAHOO! GROUPS LINKS