StaticArrays.jl
StaticArrays.jl copied to clipboard
implement Statistics.median
This implements Statistics.median
based on the existing bitonic
sorting, avoiding unnecessary allocation.
While it is generally suboptimal to sort the whole array, the compiler
manages to skip some branches since only the middle element(s) are used.
Thus median
is generally faster than sort
.
Using a dedicated median selection network could yield better performance and might be considered for future improvement.