about rolling
using RollingFunctions
๐ท๐๐ก๐ = [1, 2, 3, 4, 5]
๐น๐ข๐๐ = sum
๐๐๐๐ = 3
rolled = rolling(๐น๐ข๐๐,๐ท๐๐ก๐, ๐๐๐๐)
julia> rolled
3-element Vector{Int64}:
6
9
12
#=
The first windowed value is the ๐น๐ข๐๐ (sum) of the first ๐๐๐๐ (3) values in ๐ท๐๐ก๐.
The second windowed value is the ๐น๐ข๐๐ (sum) of the second ๐๐๐๐ (3) values in ๐ท๐๐ก๐.
The third windowed value is the ๐น๐ข๐๐ (sum) of the third ๐๐๐๐ (3) values in ๐ท๐๐ก๐.
There can be no fourth value as the third value used the fins entries in๐ท๐๐ก๐.
=#
julia> sum(๐ท๐๐ก๐[1:3]), sum(๐ท๐๐ก๐[2:4]), sum(๐ท๐๐ก๐[3:5])
(6, 9, 12)
If the width of each subsequence increases to 4..
๐๐๐๐ = 4
rolled = rolling(๐ท๐๐ก๐, ๐๐๐๐, ๐ฎ);
rolled
2-element Vector{Int64}:
10
14
Generally, with data that has r rows using a width of s results in r - s + 1 rows of values.
with matricies
#=
You have n data vectors of equal length (rowcount ๐)
๐ท๐๐ก๐โ .. ๐ท๐๐ก๐แตข .. ๐ท๐๐ก๐โ collected as an ๐ x ๐ matrix ๐
you want to apply the same function (sum)
to colum-wise triple row subsequences, successively
=#
using RollingFunctions
๐ท๐๐ก๐โ = [1, 2, 3, 4, 5]
๐ท๐๐ก๐โ = [5, 4, 3, 2, 1]
๐ท๐๐ก๐โ = [1, 2, 3, 2, 1]
๐ = hcat(๐ท๐๐ก๐โ, ๐ท๐๐ก๐โ, ๐ท๐๐ก๐โ);
#=
julia> ๐
5ร3 Matrix{Int64}:
1 5 1
2 4 2
3 3 3
4 2 2
5 1 1
=#
๐น๐ข๐๐ = sum
๐๐๐๐ = 3
result = rolling(๐น๐ข๐๐, ๐, ๐๐๐๐)
#=
julia> result
3ร3 Matrix{Int64}:
6 12 6
9 9 7
12 6 6
=#
multicolumn functions
#=
You have n data vectors of equal length (rowcount ๐)
๐ท๐๐ก๐โ .. ๐ท๐๐ก๐แตข .. ๐ท๐๐ก๐โ
you apply a function (StatsBase.cor) of n==2 arguments
to subsequences of width 3 (over successive triple rows)
=#
using RollingFunctions
๐ท๐๐ก๐โ = [1, 2, 3, 4, 5]
๐ท๐๐ก๐โ = [5, 4, 3, 2, 1]
๐น๐ข๐๐ = cor
๐๐๐๐ = 3
result = rolling(๐น๐ข๐๐,๐ท๐๐ก๐โ,๐ท๐๐ก๐โ, ๐๐๐๐)
#=
3-element Vector{Float64}:
-1.0
-1.0
-1.0
=#