nimble.calculate.percentileNormalize¶
- nimble.calculate.percentileNormalize(values1, values2=None)¶
Convert elements to a percentile.
The percentile is equal to
(k - 1) / (n - 1)wherekis the element rank in the sorted data andnis the number of values in the vector, providing elements a range of 0 to 1. When the data contains equivalent elements, the calculated percentile is the mean (equivalent to the median) of the percentiles calculated at each equal element.For elements in
values2that are not invalues1, any elements withinvalue1’s range will be calculated using linear interpolation, any elements less than the minimum ofvalues1will be set to 0 and any elements greater than the maximum ofvalues1will be set to 1.Examples
>>> lst1 = [[1], [2], [4], [4], [5]] >>> X1 = nimble.data(lst1) >>> percentileNormalize(X1) <Matrix 5pt x 1ft 0 ┌────── 0 │ 0.000 1 │ 0.250 2 │ 0.625 3 │ 0.625 4 │ 1.000 > >>> lst2 = [[3], [2], [6]] >>> X2 = nimble.data(lst2) >>> norm1, norm2 = percentileNormalize(X1, X2) >>> norm2 <Matrix 3pt x 1ft 0 ┌────── 0 │ 0.438 1 │ 0.250 2 │ 1.000 >