All problems
Phase-Space Embedding
Problem
Embed a scalar series into delay coordinates: row i is [x[i], x[i+delay], ..., x[i+(dim-1)*delay]].
Return the list of embedding vectors. Return an empty list when dim or delay is not positive, or when the series is too short to form one vector.
Hint
The number of embedded vectors is n - (dim - 1) * delay.
Test cases
case 1
in: [[1,2,3,4,5],2,1]
expected: [[1,2],[2,3],[3,4],[4,5]]
case 2
in: [[1,2,3,4],2,2]
expected: [[1,3],[2,4]]
case 3
in: [[1,2,3],3,1]
expected: [[1,2,3]]
case 4
in: [[1,2],3,1]
expected: []
Starter codePython
def phase_space_embed(series, dim, delay):
# Your code here
pass4 test cases · run your code against them in the editor