-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
ENH: numerically stable rolling_skew and rolling_kurt #8424
Conversation
Some rationale behind some of the design choices:
Timings below are on
|
Would it make sense to an a ''ddof'' argument?
|
Also, I'd suggest adding consistency checks on rolling/expanding_skew/kurt (both ddof=0 and ddof=1) to _test_moments_consistency(), test_expanding_consistency(), and test_rolling_consistency(). |
I don't think it is well defined what ddof would mean here... We could add a |
I'm not sure I agree that Inf values should be converted to NaN. I'm not sure they shouldn't, but my initial reaction is that they shouldn't be, ie should be left as is. Also, rather than explicitly masking out NaN values, why not use np.nanmean() and np.nanstd()? (I don't recall in which version of numpy they were introduced.) I suspect that will be quite a bit faster. |
Everything is unbiased by default, but (now, as of 0.15.0) is specifyable. Seems like these should be too. |
Also, if you don't mask out the |
rolling_skew
and rolling_kurt
@@ -374,6 +375,11 @@ def _rolling_moment(arg, window, func, minp, axis=0, freq=None, center=False, | |||
Passed on to func | |||
kwargs : dict | |||
Passed on to func | |||
center_data : bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put the defaults here (after bool),e .g. center_data : bool, default False
@jaimefrio, I'm not sure how
There are probably typos in the above code, so caveat emptor. |
I'll just replicate what |
@jaimefrio can you rebase/revisit ? |
@jaimefrio can you rebase and add a release note, lgtm otherwise. |
@jaimefrio can you rebase / revist ? |
Yes, will do, @jreback. Sorry I missed your earlier pings! |
@jaimefrio can you update for 0.17.0 |
can you update? |
@jaimefrio can you rebase? |
@jaimefrio can you rebase |
4afb45c
to
015d509
Compare
I've rebased, but I don't remember anymore what was missing for this to be ready... |
@@ -374,6 +375,11 @@ def _rolling_moment(arg, window, func, minp, axis=0, freq=None, center=False, | |||
Passed on to func | |||
kwargs : dict | |||
Passed on to func | |||
center_data : bool | |||
If True, subtract the mean of the data from the values | |||
norm_data: bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a versionadded directiver here
can you add the examples from top of the issue #6929 e.g. validating the problem skew/kurt results that we were getting before (IOW, calculate and compare to what they should be) |
can you add a release note in v0.17.0 (maybe a separate mini-section), to show what has changed? (e.g. you can use the same examples that show the stability problem). |
@jaimefrio can you update |
can you add a release note to 0.17.1 |
@jaimefrio can you rebase/update? |
015d509
to
d68300a
Compare
closing, but pls reopen when you can update |
Close #6929. Hat tip to @behzadnouri for the z-scores idea in #8270, and to @seth-p for the general structure of the code, separating removal and addition of observations.