Assign ranks to data, dealing with ties appropriately.
Ranks begin at 1. The method argument controls how ranks are assigned to equal values. See [1] for further discussion of ranking methods.
Parameters: |
|
---|---|
Returns: | ranks -- An array of length equal to the size of a, containing rank scores. |
Return type: | ndarray |
Notes
All floating point types are converted to numpy.float64 before ranking. This may result in spurious ties if an input array of floats has a wider data type than numpy.float64 (e.g. numpy.float128).
References
[1] | "Ranking", http://en.wikipedia.org/wiki/Ranking |
Examples
>>> rankdata([0, 2, 3, 2])
array([ 1. , 2.5, 4. , 2.5])
>>> rankdata([0, 2, 3, 2], method='min')
array([ 1., 2., 4., 2.])
>>> rankdata([0, 2, 3, 2], method='max')
array([ 1., 3., 4., 3.])
>>> rankdata([0, 2, 3, 2], method='dense')
array([ 1., 2., 3., 2.])
>>> rankdata([0, 2, 3, 2], method='ordinal')
array([ 1., 2., 4., 3.])