Added weighted median function and tests

It would be more memory-efficient to write a loop manually, computing the cumulative weight on the fly, so that you store only one value, not a whole array.