percentileofscore and multidimensional array
See original GitHub issuescipy.stats.percentileofscore seems to implicitly assume that input array “a” is a one dimensional vector. When it encounters a multidimensional matrix input, it seemingly calculates the percentile of each dimension, and SUMS them, resulting in a percentile that is potentially greater than 100?
This behaviors surprised me. I would have expected either 1) broadcasting (get back an array of percentiles), 2) reduction (get back the percentile as if the array were one dimensional), or 3) an error. My vote would be for (1), but any would be preferable to summing the percentiles.
Reproducing code example:
import numpy as np
from scipy import stats
foo = np.array([[1,2,3,4],[2,3,4,5]])
bar = stats.percentileofscore(foo, 2)
print(bar) #125
Scipy/Numpy/Python version information:
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Interpreting percentile values for a 2D array - numpy
1 Answer 1 · 25th percentile is the median of "newCol". This varies a lot between the data sets. · 50th percentile is...
Read more >Numpy Percentile: How to find it using Various Examples
Now let's find the percentile for the two-dimensional NumPy array. As it is a 2D array there are many inner cases also. For...
Read more >scipy.stats.percentileofscore — SciPy v1.9.3 Manual
Compute the percentile rank of a score relative to a list of scores. A percentileofscore of ... Array to which score is compared....
Read more >np.percentile: How to Calculate Percentile in Numpy Array
Numpy percentile() method is used to compute the ith percentile of the provided input data supplied using arrays along a specified axis.
Read more >Analysis and Optimization of Multi-dimensional Percentile ...
We propose a class of percentile mechanisms, a form of generalized median mechanisms, that are strategy-proof, and derive worst-case approxima- tion ratios for ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Well, as Option 2, at any rate.
We’ll address this as part of gh-14651.