Open bkamins opened 3 years ago
The reason is that doing partial sort twice on tails if we are near the end is faster than doing one partial sort
Why is that the case? I understand why there's no performance gain, but I wouldn't have expected it to be slower.
The reason is here https://github.com/JuliaLang/Statistics.jl/blob/54f9b0d999813aa9fab039f632df222ffd2a96a8/src/Statistics.jl#L972
for one value lo
is close to hi
and you need to sort little if you are near the boundary. But for two values where one is very low and the other is very high you have to sort almost everything.
Wow, OK. We should probably just call sort!
once for each quantile instead (which I thought we were doing). We should still benefit from the fact that we sorted some entries, right? Anyway the most common case is probably not to compute nearby quantiles (rather the contrary).
Yes, but only of 2 quantiles. Probably for more than 2 quantiles it is better to do what we do now I think.
Example:
but
The reason is that doing partial sort twice on tails if we are near the end is faster than doing one partial sort. Unfortunately this is a common case I would assume. Maybe we should introduce some optimization here?