-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve quantile: reduce allocations, use partial sort #14413
Conversation
Potential behavior changes like this are why I generally don't backport anything until I get a chance to run PackageEvaluator with the change included. |
There should also be tests of any corner cases, if there aren't yet. |
👍 |
Good point, I'll add some more tests. By the way, I forgot to mention that this add |
This performance improvement may be worth capturing in NEWS.md. |
""" | ||
quantile!([q, ] v, p; sorted=false) | ||
|
||
Compute the quantile(s) of a vector `v` at the probabilities `p`, with optional output into array `q` (if not provided, a new output array is created). The keyword argument `sorted` indicates whether `v` can be assumed to be sorted; if `false` (the default), then the elements of `v` may be partially sorted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line breaks
and should be sure the rst sig is consistent, and rerun genstdlib
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right. I haven't edited the docs since the a-doc-alypse.
ff97cdd
to
7bd187f
Compare
Okay, rebased. Hopefully this should all be good to go. |
function quantile!(v::AbstractVector, q::AbstractVector) | ||
isempty(v) && throw(ArgumentError("empty data array")) | ||
isempty(q) && throw(ArgumentError("empty quantile array")) | ||
doc""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#14378 moved almost completely away from doc"""
. Latex is now denoted by double backticks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good to know. Fixed.
7bd187f
to
f6ad90e
Compare
improve quantile: reduce allocations, use partial sort
|
||
function bound_quantiles(qs::AbstractVector) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hopefully no one was using this? only public code on github I can find that isn't a julia fork is StatsBase's own copy, so should be okay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn't exported, so I think it is safe to remove.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on master yes, but not necessarily for a backport
This improves the performance of
quantile
by reducing allocations and using a partial sort. I see a 3x improvement for large cases.It should be mostly non-breaking, but it does slightly change the behaviour of values outside the interval
[0,1]
(the previous version was a bit more lax), but I don't think this should prevent backporting.