You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Nearest sounds a lot like "nearest"? Though there is always another point about how exactly the boundaries work.
EDIT: That is, where exactly is 0 and 100 considered to be, at the datapoint or before the datapoint? (that is IIRC, anyway there are a lot of annoying complexities here)
Frankly, I think adding the C parameter would likely really be good. But mostly better documentation would be nice, and someone who really knows this stuff is needed....
I don't know if this has anything to do with the C-parameter, although I agree that the option of choosing it could be desirable.
I have found another thread that incidentally brought up this issue (Dec. 2016). It seems that the algorithm I am looking for (and which wikipedia calls nearest-rank) is mentioned in this commonly cited paper by Hyndman-Fan (H&F) as being the oldest and most studied definition of percentile (it was the one I learned in Stats course). It is a discontinuous function, so I think the parameter C does not apply here (I may be wrong).
Here is how it would look like against the other options provided by numpy that intuitively seem to compute a similar thing (i.e., 'lower', 'nearest'):
To me it looks exactly like the C parameter on first sight, the nearest curve is more stretched then the H&F curve, which is expected since numpy uses 1 and apparently H&F uses 0.
If you want proof. Repeat the whole thing with the same values repeated 1000 times, my guess is they will converge.
EDIT: Or maybe not, don't have the patience or time to really think about it. But I still think it is the C parameter wikipedia mentions, so please proof me wrong :)
@seberg I will be honest here, I don't know how the interpolation is being calculated based on the C-parameter. What makes me think that it is not related is that the C-parameter is only discussed in the linear interpolation section (Wikipedia), and both the Wikipedia and Hyndmand & Fan paper discuss the algorithm I requested in separate sections from the interpolation ones.
I don't know if there is any interpolation parameters that always give the same results as the algorithm I am interested in.
Even if there are, should this be the way used to get to it? Changing a 'strange' parameter to get the most common definition of percentile does not seem the best way to implement it imho.
@ricardoV94, maybe, but you can't just change the defaults, no matter how bad they are. We could expose something like method="H&K" to override both parameters at once.
The C parameters is where you define 0% and 100% to be with respect to the datapoints (on the data point or not, etc.). As parameter C on wikipedia, it may well be only for interpolation, but the same issue causes the difference here I am sure. C is dubious of course, a proper name might be something like range='min-max' or range='extrapolated' or probably something completely different. As I said, redo the plots with many many datapoints (possibly with tiny noise), and I think you will see them converge, since the range definition becomes less obvious.
The implementation of "the 9" is complete, I was inspired by your paper @robjhyndman as well as your library @ricardoV94 among other sources.
Would you give your OK for this feature ?
I already added a reference to the paper in the documentation, what else can I do to give the due credit ?
The implementation of "the 9" is complete, I was inspired by your paper @robjhyndman as well as your library @ricardoV94 among other sources.
Would you give your OK for this feature ?
I already added a reference to the paper in the documentation, what else can I do to give the due credit ?
I'm 100% an user and not a coder so I just wanted to add my thoughts after reading this thread and the other one related:
It's not really that important if you stick to H&F paper or Wikipedia both accomplish more or less the same thing, as long as you clearly state in the documentation: "this percentile method is based on XXXXX". The current documentation for numpy.percentile the definition of the linear interpolation is quite vague, this is why I'm here.
It is fundamental that numpy.percentile include more methods for linear interpolation, specially definition 6 from H&F which is widely used on a lot of software packages. This is necessary because the users we have to compare a lot our calculations with the calculation from a particular study. As for today numpy.percentile works only as a tool for own study but not to compare with others, which makes it less useful.
The default method is not really that relevant IMO. All of the method tend to get closer when N is large. As seen in H&F some methods have more desired properties than others but all the linear methods accomplish 5 out of 6 properties except definition 5 which accomplish all 6 properties. But I get what you said that you wanted to follow R. But why follow R and not Matlab? or not Excel? any particular reason just out of curiosity?
Hello @jiglesiasc, the 9 methods have been merged on main branch with #19857.
If everything goes right this feature should be available with numpy's next release I think.
I'm not sure if the issue should stay open though.
Activity
eric-wieser commentedon Mar 13, 2018
I think this already exists? Using the wikipedia example:
ricardoV94 commentedon Mar 13, 2018
It does not. Look at example 2 in the wikipedia page:
When it should be
[7,8,15,20]It similarly fails in the third example
seberg commentedon Mar 13, 2018
Nearest sounds a lot like "nearest"? Though there is always another point about how exactly the boundaries work.
EDIT: That is, where exactly is 0 and 100 considered to be, at the datapoint or before the datapoint? (that is IIRC, anyway there are a lot of annoying complexities here)
seberg commentedon Mar 13, 2018
don't want to read it, I think the difference might be the C parameter further down, so if someone who knows this wants to add this....
seberg commentedon Mar 13, 2018
Frankly, I think adding the C parameter would likely really be good. But mostly better documentation would be nice, and someone who really knows this stuff is needed....
ricardoV94 commentedon Mar 13, 2018
I don't know if this has anything to do with the C-parameter, although I agree that the option of choosing it could be desirable.
I have found another thread that incidentally brought up this issue (Dec. 2016). It seems that the algorithm I am looking for (and which wikipedia calls nearest-rank) is mentioned in this commonly cited paper by Hyndman-Fan (H&F) as being the oldest and most studied definition of percentile (it was the one I learned in Stats course). It is a discontinuous function, so I think the parameter C does not apply here (I may be wrong).
Here is how it would look like against the other options provided by numpy that intuitively seem to compute a similar thing (i.e., 'lower', 'nearest'):
seberg commentedon Mar 13, 2018
To me it looks exactly like the C parameter on first sight, the nearest curve is more stretched then the H&F curve, which is expected since numpy uses 1 and apparently H&F uses 0.
seberg commentedon Mar 13, 2018
If you want proof. Repeat the whole thing with the same values repeated 1000 times, my guess is they will converge.
EDIT: Or maybe not, don't have the patience or time to really think about it. But I still think it is the C parameter wikipedia mentions, so please proof me wrong :)
eric-wieser commentedon Mar 13, 2018
A graph like that would be a great addition to the percentile docs
edit: preferably one showing the open/closedness of the discontinuities
Note to readers: To keep this thread manageable, I've marked all discussions below about adding this graph to the docs as "resolved". The graph is now at the bottom of https://numpy.org/devdocs/reference/generated/numpy.percentile.html.
ricardoV94 commentedon Mar 13, 2018
ricardoV94 commentedon Mar 13, 2018
@seberg I will be honest here, I don't know how the interpolation is being calculated based on the C-parameter. What makes me think that it is not related is that the C-parameter is only discussed in the linear interpolation section (Wikipedia), and both the Wikipedia and Hyndmand & Fan paper discuss the algorithm I requested in separate sections from the interpolation ones.
I don't know if there is any interpolation parameters that always give the same results as the algorithm I am interested in.
Even if there are, should this be the way used to get to it? Changing a 'strange' parameter to get the most common definition of percentile does not seem the best way to implement it imho.
seberg commentedon Mar 13, 2018
@ricardoV94, maybe, but you can't just change the defaults, no matter how bad they are. We could expose something like method="H&K" to override both parameters at once.
The C parameters is where you define 0% and 100% to be with respect to the datapoints (on the data point or not, etc.). As parameter
Con wikipedia, it may well be only for interpolation, but the same issue causes the difference here I am sure.Cis dubious of course, a proper name might be something like range='min-max' or range='extrapolated' or probably something completely different. As I said, redo the plots with many many datapoints (possibly with tiny noise), and I think you will see them converge, since the range definition becomes less obvious.ricardoV94 commentedon Mar 13, 2018
@seberg I am fine with method="H&K" or maybe method="classic". Interpolation="none" could also make sense.
eric-wieser commentedon Mar 13, 2018
69 remaining items
[numpy#10736] Update nanquantile
[numpy#10736] Update nanquantile
abel-bzz commentedon Sep 16, 2021
The implementation of "the 9" is complete, I was inspired by your paper @robjhyndman as well as your library @ricardoV94 among other sources.
Would you give your OK for this feature ?
I already added a reference to the paper in the documentation, what else can I do to give the due credit ?
robjhyndman commentedon Sep 16, 2021
Not sure what you want my OK for. But happy to see this implemented in python. A reference to the 1996 paper is sufficient.
ricardoV94 commentedon Sep 17, 2021
No need to mention my library :)
MAINT, ENH [numpy#10736] Add interpolation methods to quantile
MAINT, ENH [numpy#10736] Add interpolation methods to quantile
MAINT, ENH [numpy#10736] Add interpolation methods to quantile
MAINT, ENH [numpy#10736] Add interpolation methods to quantile
MAINT, ENH [numpy#10736] Add interpolation methods to quantile
jiglesiasc commentedon Nov 8, 2021
I'm 100% an user and not a coder so I just wanted to add my thoughts after reading this thread and the other one related:
abel-bzz commentedon Nov 8, 2021
Hello @jiglesiasc, the 9 methods have been merged on main branch with #19857.
If everything goes right this feature should be available with numpy's next release I think.
I'm not sure if the issue should stay open though.
seberg commentedon Nov 8, 2021
Yeah, lets close it. The main thing is that I want to quickly follow-up to rename
interpolationtomethod. If anyone here has further hints/suggestions, please also check the new docs: https://numpy.org/devdocs/reference/generated/numpy.quantile.html changing names, etc. should happen within the next few weeks (or we miss the next release).I think the current docs are good, but a snippet of text to guide users towards (safe) choices may be nice.