All problems
SSA Trajectory Matrix Build
Problem
Build the trajectory (Hankel) matrix used by singular spectrum analysis. With window length L, row i is series[i : i+L] for i = 0, ..., n-L.
Return a list of L-length rows, or an empty list if window is not positive or exceeds the series length.
Hint
The matrix is constant along its anti-diagonals.
Test cases
case 1
in: [[1,2,3,4,5],3]
expected: [[1,2,3],[2,3,4],[3,4,5]]
case 2
in: [[1,2],2]
expected: [[1,2]]
case 3
in: [[1,2],0]
expected: []
case 4
in: [[1,2,3],5]
expected: []
Starter codePython
def ssa_trajectory_matrix(series, window):
# Your code here
pass4 test cases · run your code against them in the editor