[Numpy-discussion] Adding weights to cov and corrcoef

Sebastian Berg sebastian at sipsolutions.net
Wed Mar 5 11:45:47 EST 2014


Hi all,

in Pull Request https://github.com/numpy/numpy/pull/3864 Neol Dawe
suggested adding new parameters to our `cov` and `corrcoef` functions to
implement weights, which already exists for `average` (the PR still
needs to be adapted).

The idea right now would be to add a `weights` and a `frequencies`
keyword arguments to these functions.

In more detail: The situation is a bit more complex for `cov` and
`corrcoef` than `average`, because there are different types of weights.
The current plan would be to add two new keyword arguments:
  * weights: Uncertainty weights which causes `N` to be recalculated
    accordingly (This is R's `cov.wt` default I believe).
  * frequencies: When given, `N = sum(frequencies)` and the values
    are weighted by their frequency.

Because it appeared that the uncertainty type of weights are not
obvious, while other types of weights should be pretty easily
implemented by scaling `frequencies` (i.e. one may want
`sum(frequencies) == len(data)`).

However, we may have missed something obvious, or maybe it is already
getting too statistical for NumPy, or the keyword argument might be
better `uncertainties` and `frequencies`. So comments and insights are
very welcome :).

Regards,

Sebastian




More information about the NumPy-Discussion mailing list