Modified implementation of BM_median. It now returns a float and handles arrays with an even number of elements.