JeffreySarnoff / RollingFunctions.jl

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

trailing average ? #30

Closed bjarthur closed 1 year ago

bjarthur commented 1 year ago

is it possible to compute using this package? i see OffsetWindow in src, but it is not documented.

JeffreySarnoff commented 1 year ago

Hi. The package is working just fine -- what you are seeing is some steps forward to the next version. The version that is released, and available through the package manager is well-tested and in broad use. Follow the guidance and examples here. Ignore anything else until there is an announcement.

bjarthur commented 1 year ago

so a trailing average is not supported in the current version, but you're working on it for the next? that would be great!

JeffreySarnoff commented 1 year ago

explain exactly what you mean by trailing average -- please give me a tiny example (or just part of one) what you want may be available with the current code base

bjarthur commented 1 year ago

the window only averages over past time samples. it's not symmetric about the current point.

JeffreySarnoff commented 1 year ago

None of these functions operate about a current data value. The windowing functions proceed from long ago to right now, one index at a time. So: we are given a sequence of 7 values [say, each one is observed at noon on its associated day of the week] and we roll the function sum over a sliding window of span 4. The first day on which a summary value is available is day 4; that initial summand is developed using observations 1, 2, 3, and 4. Until day 4, there are not 4 values to be summed. The windowed sum (or whatever unary aggregative function you choose) rolls over the data and yields 3 fewer summary values than there are data values. The first three summary values do not exist.

This package does support running a function in a window that slides over data. Unlike rolling a function, there will be just as many summary values as there are data values, the initial summary values are approximate summarizations. The first value is a copy of the first data value, the second is (say) the average of the first two data values * 4, the third is similar, and only at the fourth does the summary value become calculated accurately.

The averages are taken over past time samples, including the most recent observation (the very recent past).

bjarthur commented 1 year ago

great! you perhaps might want to make this clear in your docs. i don't see that mentioned.