-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Implement rolling_product
#9954
Comments
@stinodego I can take a shot at this, since One thing that I'm wondering about is the pl.Series([1, 2, 3, 4, 5, 6]).rolling_sum(window_size=4, min_periods=1,center=True)
shape: (6,)
Series: '' [i64]
[
3
6
10
14
18
15
] I can try to break this down. An
I think the rule here is a little simple: If we have an even number of bins, wait until we reach one of the middle two bins, then start to build the output array. Stop when our output array is the same size as the input array. |
|
@magarick I have an almost-implementation ready, but yes I'm running into your second point about updating the window. The rolling sum can easily subtract values when we go past the edge, but you can't undo a multiplication by zero, so we need some form of memory, or better edge detection. To be honest, I'm not entirely comfortable what the "if we exceed the end, we have a completely new window so we recompute" part does or when it's called. I was thinking of looking into ways to consolidate, but in this case where we're just adding rolling product, it didn't seem worth it to spend the extra energy. I can't think of other simple arithmetic rollers (rolling exponent is absurd, rolling division doesn't really make sense) so this doesn't seem like opening the door to other rolling functions that aren't significantly more complex. |
FYI I just found where you reference #9277 (comment) so I'm reading that. |
Oh, for consolidate I just meant some way of tracking. It wasn't a suggestion for doing this any differently. But I can imagine simple things like rolling geometric means or application of smoothing kernels, as well as more complex, like refactoring to produce multiple quantiles at once and avoid wasting work. Hopefully that documentation is helpful. I probably need to update it to include the new version that accounts for sorted runs. I think you can use a similar technique for the product and keep track of the most recent zero in the series. If that's in your window you know you don't need to do any work. But even if you're going between two zero-free windows, I think there's some trouble with multiplying and dividing. It might be better to keep track of the signs separately and do log-sum-exp on the absolute values. |
Thanks @magarick. With @SeanTroyUWO's help I managed to set up debugging/breakpointing rust called from python and it's helping a lot. I see with Let me think about the log-sum-exp. While mathematically identcal, doing these shenanigans with floating points can muck things up in some cases. |
I didn't implement rolling sum, but I've touched the code. I would like to learn more about this way of debugging too! |
Re: the debugging, I'm going to write up a guide. I'm attempting to streamline it at the moment, as right now it involves a couple steps/keyboard strokes and it would be nice to get it into one single config. |
Problem description
As mentioned in #8437
This functionality is currently missing. Would be nice to have, seeing as we have lots of other rolling functionality.
The text was updated successfully, but these errors were encountered: