ENH: Add Moving Average Function

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

ENH: Add Moving Average Function

NGeorgescu
Hi all,

I opened a Pull Request to include this package in numpy, along with the associated sliding window function in this PR.

The function picks the fastest method to do a moving average if there is no weighting, but with weights it resorts to the second-fastest method which has an easier implementation.  It also contains a binning option which cuts the number of points down by a factor of n rather than by subtracting n.  The details are in the package documentation and PR.

Thanks,
Nicholas
Sent from Mailspring
_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|

Re: ENH: Add Moving Average Function

Stephan Hoyer-2
I would be very interested to see the “sliding window view” function merged into np.lib.stride_tricks.

I don’t think it makes sense to add a suite of dedicated functions for sliding window calculations that wrap that function. If we are going to go down the path of adding sliding window calculations into a NumPy, they should use efficient algorithms, like those found in the “bottleneck” package.

Best,
Stephan

On Sun, Aug 25, 2019 at 3:33 PM Nicholas Georgescu <[hidden email]> wrote:
Hi all,

I opened a Pull Request to include this package in numpy, along with the associated sliding window function in this PR.

The function picks the fastest method to do a moving average if there is no weighting, but with weights it resorts to the second-fastest method which has an easier implementation.  It also contains a binning option which cuts the number of points down by a factor of n rather than by subtracting n.  The details are in the package documentation and PR.

Thanks,
Nicholas
Sent from Mailspring_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|

Re: ENH: Add Moving Average Function

Todd
I think having some function for common cases like moving average and spectrogram would be good.  Having a jumping-off point and simple reference for testing against could encourage someone to make a faster implementation down the road.

-Todd

On Mon, Aug 26, 2019 at 12:24 AM Stephan Hoyer <[hidden email]> wrote:
I would be very interested to see the “sliding window view” function merged into np.lib.stride_tricks.

I don’t think it makes sense to add a suite of dedicated functions for sliding window calculations that wrap that function. If we are going to go down the path of adding sliding window calculations into a NumPy, they should use efficient algorithms, like those found in the “bottleneck” package.

Best,
Stephan

On Sun, Aug 25, 2019 at 3:33 PM Nicholas Georgescu <[hidden email]> wrote:
Hi all,

I opened a Pull Request to include this package in numpy, along with the associated sliding window function in this PR.

The function picks the fastest method to do a moving average if there is no weighting, but with weights it resorts to the second-fastest method which has an easier implementation.  It also contains a binning option which cuts the number of points down by a factor of n rather than by subtracting n.  The details are in the package documentation and PR.

Thanks,
Nicholas
Sent from Mailspring_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|

Re: ENH: Add Moving Average Function

ralfgommers


On Mon, Aug 26, 2019 at 8:38 AM Todd <[hidden email]> wrote:
I think having some function for common cases like moving average and spectrogram would be good.  Having a jumping-off point and simple reference for testing against could encourage someone to make a faster implementation down the road.

This could also be done as a docstring example in the sliding window view function. It's pretty straightforward, the moving average function in PR 13923 (fnjn_mvgavg) is ~5 lines of code.

That way we don't get stuck with a function that's not as efficient as it should be, and we can point from there to `bottleneck` and/or something else that's a high-quality implementation.

Cheers,
Ralf

 

-Todd

On Mon, Aug 26, 2019 at 12:24 AM Stephan Hoyer <[hidden email]> wrote:
I would be very interested to see the “sliding window view” function merged into np.lib.stride_tricks.

I don’t think it makes sense to add a suite of dedicated functions for sliding window calculations that wrap that function. If we are going to go down the path of adding sliding window calculations into a NumPy, they should use efficient algorithms, like those found in the “bottleneck” package.

Best,
Stephan

On Sun, Aug 25, 2019 at 3:33 PM Nicholas Georgescu <[hidden email]> wrote:
Hi all,

I opened a Pull Request to include this package in numpy, along with the associated sliding window function in this PR.

The function picks the fastest method to do a moving average if there is no weighting, but with weights it resorts to the second-fastest method which has an easier implementation.  It also contains a binning option which cuts the number of points down by a factor of n rather than by subtracting n.  The details are in the package documentation and PR.

Thanks,
Nicholas
Sent from Mailspring_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion