Skip to content

Instantly share code, notes, and snippets.

@christabor
Created August 12, 2015 04:27
Show Gist options
  • Save christabor/10f141d6e276269e5f91 to your computer and use it in GitHub Desktop.
Save christabor/10f141d6e276269e5f91 to your computer and use it in GitHub Desktop.
Random time series warping
from random import randrange as rr
# Use with: http://mlpy.sourceforge.net/docs/3.5/dtw.html#id3
def random_timesequence(start, end, steps=3):
seq = []
for n in range(start, end):
# Randomize the number of sub-steps,
# but maintain the bounds and monotonicity
# (e.g. 0, 0, 1, 1, 1, 2, 3, 3, 3)
for i in range(rr(0, steps)):
seq.append(n)
return seq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment