JeffreySarnoff / RollingFunctions.jl

Roll a window over data; apply a function over the window.
MIT License
114 stars 6 forks source link

FR: support for minimum window size #13

Closed ValdarT closed 5 years ago

ValdarT commented 5 years ago

It would be nice if there was a way to specify a minimum window size for calculations in case not enough data is available. For example, a rollmean with windowsize of 3 and minimum window size of 2 would not calculate anything for the first entry of the input array, mean of the first 2 entries of the input array for the second item and mean of 3 entries going forward. FWIW, Python's Pandas supports this with argument called min_periods: https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.rolling.html

PS: I understand that the philosophy of this package is to keep it simple but to me this feels like something that would more naturally fit here instead of another "layer" package built "on top" of this one.

JeffreySarnoff commented 5 years ago

rollmean with a windowsize of w1 and a minimum window size of w0 (w1 > w0 > 0): runmean(datavec, w1)[w0:end] or view(runmean(datavec, w1), w0:end)

ValdarT commented 5 years ago

Indeed. Sorry for the noise :)