Added weighted median function and tests

You can update your existing fork and this pull request will reflect the changes.