Joseph Fox-Rabinovitz
2016-02-16 05:49:42 UTC
I would like to add a `weights` keyword to `np.partition`,
`np.percentile` and `np.median`. My reason for doing so is to to allow
`np.histogram` to process automatic bin selection with weights.
Currently, weights are not supported for the automatic bin selection
and would be difficult to support in `auto` mode without having
`np.percentile` support a `weights` keyword. I suspect that there are
many other uses for such a feature.
I have taken a preliminary look at the C implementation of the
partition functions that are the basis for `partition`, `median` and
`percentile`. I think that it would be possible to add versions (or
just extend the functionality of existing ones) that check the ratio
of the weights below the partition point to the total sum of the
weights instead of just counting elements.
One of the main advantages of such an implementation is that it would
allow any real weights to be handled correctly, not just integers.
Complex weights would not be supported.
The purpose of this email is to see if anybody objects, has ideas or
cares at all about this proposal before I spend a significant amount
of time working on it. For example, did I miss any functions in my
list?
Regards,
-Joe
`np.percentile` and `np.median`. My reason for doing so is to to allow
`np.histogram` to process automatic bin selection with weights.
Currently, weights are not supported for the automatic bin selection
and would be difficult to support in `auto` mode without having
`np.percentile` support a `weights` keyword. I suspect that there are
many other uses for such a feature.
I have taken a preliminary look at the C implementation of the
partition functions that are the basis for `partition`, `median` and
`percentile`. I think that it would be possible to add versions (or
just extend the functionality of existing ones) that check the ratio
of the weights below the partition point to the total sum of the
weights instead of just counting elements.
One of the main advantages of such an implementation is that it would
allow any real weights to be handled correctly, not just integers.
Complex weights would not be supported.
The purpose of this email is to see if anybody objects, has ideas or
cares at all about this proposal before I spend a significant amount
of time working on it. For example, did I miss any functions in my
list?
Regards,
-Joe