The RANKS function computes the magnitude-based ranks of a sample population X. Elements of identical magnitude “ties” are ranked according to the mean of the ranks that would otherwise be assigned.
This routine is written in the IDL language. Its source code can be found in the file ranks.pro in the lib subdirectory of the IDL distribution.
Examples
X = [-0.8, 0.1, -2.3, -0.6, 0.2, 1.1, -0.3, 0.6, -0.2, 1.1, $
-0.7, -0.2, 0.6, 0.4, -0.1, 1.1, -0.3, 0.3, -1.3, 1.1]
array = FLTARR(2, N_ELEMENTS(X))
array[0, *] = X[SORT(X)]
array[1, *] = RANKS(X[SORT(X)])
PRINT, array, FORMAT = '(2(5x, f5.2))'
IDL prints:
-2.30 1.00
-1.30 2.00
-0.80 3.00
-0.70 4.00
-0.60 5.00
-0.30 6.50
-0.30 6.50
-0.20 8.50
-0.20 8.50
-0.10 10.00
0.10 11.00
0.20 12.00
0.30 13.00
0.40 14.00
0.60 15.50
0.60 15.50
1.10 18.50
1.10 18.50
1.10 18.50
1.10 18.50
Syntax
Result = RANKS(X)
Return Value
The result is a vector of ranks equal in length to X.
Arguments
X
An n-element integer, single-, or double-precision floating-point vector. The elements of this vector must be in ascending order based on their magnitude.
Keywords
None.
Version History
See Also
R_CORRELATE