scipy.stats.rankdata

scipy.stats.rankdata(a)

Assign ranks to the data in a, dealing with ties appropriately.

Equal values are assigned a rank that is the average of the ranks that would have been otherwise assigned to all of the values within that set. Ranks begin at 1.

Parameters :

a : array_like

This array is first flattened.

Returns :

ranks : ndarray

An array of length equal to the size of a, containing rank scores.

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).

Examples

>>> rankdata([0, 2, 3, 2])
array([ 1. ,  2.5,  4. ,  2.5])

Previous topic

scipy.stats.tiecorrect

Next topic

scipy.stats.ranksums