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

IDL 5.2.1 bug? R_Correlate & IDL_Crank

Has anyone discovered this problem?  I've been doing some heavy data
analysis using IDL's rank correlation function:

rank = r_correlate( xarray, yarray)

where "xarray" and "yarray" are both 881-element vectors (with a lot of
ties).  The problem is that I get drastically different
rank correlation numbers between IDL's r_correlate routine and the
Numerical Recipes Fortran "spear" routine that does the
same thing.  Since IDL basically uses the NR routines these should be
identical, however, I traced the problem to IDL's
idl_crank.pro function in which this statement

s=s + t^3 - t

gives the incorrect result, when comparing line by line with the Fortran
code.  The reason is that "t" is computed with integer
values - in the previous line t=jt-j (both "jt" and "j" are integers);
and if "t" is large (which it is in my case), then "t^3"
becomes greater than 32,256 and returns a negative number.  A simple fix
is to replace this line at the beginning of the


with this line


This forces "t" to become a floating point variable and makes both IDL
and NR Fortran routines give identical rank correlation numbers for
identical data sets.  Anyone else have this problem or know of any more
IDL mathematical routines that have similar bugs?


Sent via Deja.com http://www.deja.com/
Before you buy.