There are O(n) algorithms for finding a median, yet Matlab uses an O(n log n) algo (sorting an entire list, then taking the middle element). Here is a nicely written mex file that performs medians faster (on my computer, about 3x faster).
There are O(n) algorithms for finding a median, yet Matlab uses an O(n log n) algo (sorting an entire list, then taking the middle element). Here is a nicely written mex file that performs medians faster (on my computer, about 3x faster).