Skip to content

ENH: Weight support for np.var #5164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MechCoder opened this issue Oct 9, 2014 · 6 comments
Closed

ENH: Weight support for np.var #5164

MechCoder opened this issue Oct 9, 2014 · 6 comments

Comments

@MechCoder
Copy link
Contributor

Is there any reason why there is no weights keyword for np.var similar to np.average? We sometimes need to custom code for this in sklearn sometimes, for example, Here

If this is agreed upon, I can submit a Pull Request.

@MechCoder MechCoder changed the title ENH: Sample weight support for np.var ENH: Weight support for np.var Oct 9, 2014
@seberg
Copy link
Member

seberg commented Oct 9, 2014

Check out and work on gh-4960, it might be pretty much done even, but a couple of extra eyes are probably necessary in any case.

@seberg
Copy link
Member

seberg commented Oct 9, 2014

Nvm. you mean var not covariance, but that might have similar problems, at least when you get into ddof != 1, so it would be good to synchronize such decision.

@tpoole
Copy link
Contributor

tpoole commented Apr 26, 2015

A weighted variance is calculated in exactly the same way as a single-variable weighted covariance.

@charris
Copy link
Member

charris commented May 14, 2015

Weights are available for cov since #4960 has been merged. @MechCoder Check it out. It isn't quite as convenient as the ndarray.var method, but should suffice. In fact, the var method is implemented in numpy/core/_methods.py, so it probably would not be difficult to use bits of the code in #4960 to implement weights. Make a PR if you wish.

@MechCoder
Copy link
Contributor Author

Sorry for the non-replying. I shall have a look right now.

@melissawm
Copy link
Member

I believe the discussion here is similar to #8581, so this can be closed in favor of that issue. Please reopen if this is not the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants