Reputation: 3429
I am trying to find the best way to match a user generated sequence of numbers against a predefined sequence. For example, I have the sequences 1,2,3,4 and 4,3,2,1, The user can generate a sequence using any of those numbers (including omitting some) e.g. 2,3,4 / 4,3,1 / 1,2,3,2,1. I'm thinking about assigning a score based on the difference of each number in the sequence but I'm not sure if there's a more optimal solution.
Upvotes: 1
Views: 176
Reputation: 4661
You can look up dynamic time warping for one possible solution, see e.g. en.wikipedia.org/wiki/Dynamic_time_warping. Note that a numeric sequence can be regarded as a time series, and also you can align two sequences by multiplying the "time" index by a scalar multiple so that the two sequences have the same start and end time. Or you can just leave the time index equal to the sequence index without scaling.
Upvotes: 1