# Stats on expanding or moving data windows

**URL:** <https://discourse.julialang.org/t/stats-on-expanding-or-moving-data-windows/75534>\
**Category:** General Usage\
**Tags:** statistics\
**Created:** [January 31, 2022, 7:48pm UTC](https://discourse.julialang.org/t/stats-on-expanding-or-moving-data-windows/75534 "2022-01-31T19:48:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_Soderlind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_soderlind/32/1753_2.png) [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)\
**Post date:** [January 31, 2022, 7:48pm UTC](https://discourse.julialang.org/t/stats-on-expanding-or-moving-data-windows/75534/1 "2022-01-31T19:48:59Z")

</div>

I am coding up functions for means/std/corr/OLS on expanding/moving inclusion/moving exclusion windows. So far, a simple approach (mostly loops) seems to provide pretty nice performance.

My question: is this already done in a package?

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [January 31, 2022, 8:00pm UTC](https://discourse.julialang.org/t/stats-on-expanding-or-moving-data-windows/75534/2 "2022-01-31T20:00:04Z")

</div>

[RollingFunctions.jl](https://github.com/JeffreySarnoff/RollingFunctions.jl) is one example.

If you want something that eeks out even more performance you can use StaticKernels.jl as I started to do in my kitchen-sink package [https://github.com/tbeason/SantasLittleHelpers.jl](https://github.com/tbeason/SantasLittleHelpers.jl) or I also have done some work using Tullio.jl and found it to be even faster.

---

<div class="post-metadata">

**Author:** ![Paul\_Soderlind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_soderlind/32/1753_2.png) [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)\
**Post date:** [January 31, 2022, 8:26pm UTC](https://discourse.julialang.org/t/stats-on-expanding-or-moving-data-windows/75534/3 "2022-01-31T20:26:25Z")

</div>

Thanks. That looks interesting.

May I ask about your experience with StaticKernels.jl when the kernel gets “big”? For instance, if the moving data window includes 1\_000 data points.

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [January 31, 2022, 9:08pm UTC](https://discourse.julialang.org/t/stats-on-expanding-or-moving-data-windows/75534/4 "2022-01-31T21:08:22Z")

</div>

I would think that is too large for that approach. In this case, writing your own with Tullio.jl and LoopVectorization.jl will probably be the fastest.

I spent a day tooling around with the approach here: [https://github.com/tbeason/TullioStatistics.jl](https://github.com/tbeason/TullioStatistics.jl)

Unfortunately, the rolling window stuff didn’t get completed in that day and I haven’t revisited it since… but I do remember that I had already tested rolling means, std, etc and it was much faster than the approach in RollingFunctions.jl.
