Example #1
0
def cdtw(query, subject, window, squared=True):
    """constrained Euclidean-flavoured DTW """
    
    return ldtw.dist_cdtw(ldtw.TimeSeries(query), ldtw.TimeSeries(subject), window, squared)
Example #2
0
# calculate envelope with window length w
w = 50
dtw.lb_envelope(Q, w, L, U)

# plot the envelope for the query
pl.plot(Q)
pl.plot(L)
pl.plot(U)
pl.show()

# generate a sine wave as subject
S = dtw.TimeSeries(np.sin(T))

# mode (Euclidean flavoured: True, Manhatten flavoured: False)
mode = True

# calculate lower bounds and associated constrained DTW measure
print "lb_Keogh on query", \
      dtw.lb_keogh_onQuery(Q, S, w, mode), \
      dtw.lb_keogh_onEnvelope(S, L, U, w, mode)

# now on subject
dtw.lb_envelope(S, w, L, U)
print "lb_Keogh on subject", \
      dtw.lb_keogh_onSubject(Q, S, w, mode), \
      dtw.lb_keogh_onEnvelope(Q, L, U, w, mode)

# the constrained DTW measure
print "constrained DTW", \
      dtw.dist_cdtw(Q, S, w, mode)
Example #3
0
# calculate envelope with window length w
w = 50
dtw.lb_envelope(Q, w, L, U)

# plot the envelope for the query
pl.plot(Q)
pl.plot(L)
pl.plot(U)
pl.show()

# generate a sine wave as subject
S = dtw.TimeSeries(np.sin(T))

# mode (Euclidean flavoured: True, Manhatten flavoured: False)
mode = True

# calculate lower bounds and associated constrained DTW measure
print "lb_Keogh on query", \
      dtw.lb_keogh_onQuery(Q, S, w, mode), \
      dtw.lb_keogh_onEnvelope(S, L, U, w, mode)

# now on subject
dtw.lb_envelope(S, w, L, U)
print "lb_Keogh on subject", \
      dtw.lb_keogh_onSubject(Q, S, w, mode), \
      dtw.lb_keogh_onEnvelope(Q, L, U, w, mode)
      
# the constrained DTW measure
print "constrained DTW", \
      dtw.dist_cdtw(Q, S, w, mode)
Example #4
0
def cdtw(query, subject, window, squared=True):
    """constrained Euclidean-flavoured DTW """

    return ldtw.dist_cdtw(ldtw.TimeSeries(query), ldtw.TimeSeries(subject),
                          window, squared)