Rank transformation replaces each value with its one-based position in ascending order. The smallest value receives rank 1. When equal values occupy several positions, assign all of them the average of those positions.
Return ranks in the original input order so each output position corresponds to the value at the same input position.
Input: values = [10, 30, 20]
Output: [1.0, 3.0, 2.0]
Explanation: Sorting gives 10, 20, 30, whose ranks are 1, 2, and 3 before restoring the original order.
Input: values = [1, 2, 2, 3]
Output: [1.0, 2.5, 2.5, 4.0]
Sort input indices by their corresponding values.
Process equal values as one consecutive group in the sorted index list.
Sign in to take notes on this problem
Accepts: array
Rank transformation replaces each value with its one-based position in ascending order. The smallest value receives rank 1. When equal values occupy several positions, assign all of them the average of those positions.
Return ranks in the original input order so each output position corresponds to the value at the same input position.
Input: values = [10, 30, 20]
Output: [1.0, 3.0, 2.0]
Explanation: Sorting gives 10, 20, 30, whose ranks are 1, 2, and 3 before restoring the original order.
Input: values = [1, 2, 2, 3]
Output: [1.0, 2.5, 2.5, 4.0]
Sort input indices by their corresponding values.
Process equal values as one consecutive group in the sorted index list.
Sign in to take notes on this problem
Accepts: array