question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

percentileofscore and multidimensional array

See original GitHub issue

scipy.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:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rkerncommented, Jul 16, 2021

Well, as Option 2, at any rate.

0reactions
mdhabercommented, Mar 13, 2022

We’ll address this as part of gh-14651.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found