@@ -35,31 +35,32 @@ possible for excess observations to be omitted from the view.
35
35
Note that the windows are not materialized at construction time.
36
36
To actually get a copy of the data at some window use indexing or [`getobs`](@ref).
37
37
38
+ When indexing the data is accessed as `getobs(data, idxs)`, with `idxs` an appropriate range of indexes.
38
39
```jldoctest
39
- julia> s = slidingwindow(1:20 , size=6)
40
- slidingwindow(1:20 , size=6, stride=1)
40
+ julia> s = slidingwindow(11:30 , size=6)
41
+ slidingwindow(10:30 , size=6, stride=1)
41
42
42
- julia> s[1]
43
- 1:6
43
+ julia> s[1] # == getobs(data, 1:6)
44
+ 11:16
44
45
45
- julia> s[2]
46
- 2:7
46
+ julia> s[2] # == getobs(data, 2:7)
47
+ 12:17
47
48
```
48
49
49
50
The optional parameter `stride` can be used to specify the
50
51
distance between the start elements of each adjacent window.
51
52
By default the stride is equal to 1.
52
53
53
54
```jldoctest
54
- julia> s = slidingwindow(1:20 , size=6, stride=3)
55
+ julia> s = slidingwindow(11:30 , size=6, stride=3)
55
56
slidingwindow(1:20, size=6, stride=3)
56
57
57
58
julia> for w in s; println(w); end
58
- 1:6
59
- 4:9
60
- 7:12
61
- 10:15
62
- 13:18
59
+ 11:16
60
+ 14:19
61
+ 17:22
62
+ 20:25
63
+ 23:28
63
64
```
64
65
"""
65
66
function slidingwindow (data; size:: Int , stride:: Int = 1 )
0 commit comments