The weighted median of a sample is the 50% weighted percentile (see this post @ crossvalidated for more info)/
I was wondering how one would extend the algorithm used to find the median of a running stream of numbers detailed here (with two heaps, a min heap for the left side and a max heap for the right side) to efficiently calculate the weighted median from a stream of double
values and weights.
One idea I had was to use the same method as when calculating the median from an unweighted stream of numbers, but simply put in extra values if the weights are not one (e.g. a value with a weight of 2 would be inserted twice). However, this doesn't scale well with weights that can be doubles, and also seems quite memory inefficient.
Thanks!