Added weighted median function and tests

It might be good to have some cases with zero weights here to test that part of the code.