TD_DTW Function Examples | Teradata Vantage - TD_DTW Examples - Teradata Vantage

Database Unbounded Array Framework Time Series Functions

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-10-04
dita:mapPath
ncd1634149624743.ditamap
dita:ditavalPath
ruu1634160136230.ditaval
dita:id
ncd1634149624743

TD_DTW Input Tables

Input Table dtw_t1
id seq v
1 2019-01-05 4.50000
1 2019-01-04 3.50000
1 2019-01-01 0.50000
1 2019-01-02 1.50000
1 2019-01-03 2.50000
2 2020-01-04 3.00000
2 2020-01-05 4.00000
2 2020-01-03 2.00000
2 2020-01-01 0.00000
2 2020-01-02 1.00000
Input Table dtw_t2
id seq v
1 2001-01-02 2.00000
1 2001-01-01 1.00000
1 2001-01-03 3.00000

Example: TD_DTW Call with No FUNC_PARAMS

EXECUTE FUNCTION TD_DTW
(
   SERIES_SPEC(TABLE_NAME(dtw_t1),ROW_AXIS(TIMECODE(seq)), SERIES_ID(id),
      PAYLOAD(FIELDS(v), CONTENT(REAL))),
   SERIES_SPEC(TABLE_NAME(dtw_t2),ROW_AXIS(TIMECODE(seq)), SERIES_ID(id),
      PAYLOAD(FIELDS(v),CONTENT(REAL))) WHERE (id) = 1,
   INPUT_FMT(INPUT_MODE(MANY2ONE))
);

TD_DTW Output with No FUNC_PARAMS

id                  ROW_I            WarpDistance
------  --------------------  ----------------------
1                     0   3.50000000000000E 000
2                     0   2.00000000000000E 000

Example: TD_DTW Call with WARPPATH(1)

EXECUTE FUNCTION TD_DTW(
   SERIES_SPEC(TABLE_NAME(dtw_t1), ROW_AXIS(TIMECODE(seq)),SERIES_ID(id),
      PAYLOAD(FIELDS(v),CONTENT(REAL))),
   SERIES_SPEC(TABLE_NAME(dtw_t2), ROW_AXIS(TIMECODE(seq)),SERIES_ID(id),
      PAYLOAD(FIELDS(v), CONTENT(REAL))) WHERE (id) = 1,
   INPUT_FMT(INPUT_MODE(MANY2ONE)),
   FUNC_PARAMS(WARPPATH(1) )
);

DT_DTW Output with WARPPATH(1)

id                  ROW_I            WarpDistance                  WarpX                  WarpY
-----------  --------------------  ----------------------  --------------------  
--------------------
1                     0   5.00000000000000E-001                     0                     0
1                     1   1.00000000000000E 000                     1                     0
1                     2   1.50000000000000E 000                     2                     1
1                     3   2.00000000000000E 000                     3                     2
1                     4   3.50000000000000E 000                     4                     2
2                     0   1.00000000000000E 000                     0                     0
2                     1   1.00000000000000E 000                     1                     0
2                     2   1.00000000000000E 000                     2                     1
2                     3   1.00000000000000E 000                     3                     2
2                     4   2.00000000000000E 000                     4                     2

Example: TD_DTW Call with WARPPATH(2)

EXECUTE FUNCTION TD_DTW(
   SERIES_SPEC(TABLE_NAME(dtw_t1), ROW_AXIS(TIMECODE(seq)), SERIES_ID(id),
      PAYLOAD(FIELDS(v),CONTENT(REAL))),
   SERIES_SPEC(TABLE_NAME(dtw_t2), ROW_AXIS(TIMECODE(seq)), SERIES_ID(id),
      PAYLOAD(FIELDS(v),CONTENT(REAL)))WHERE (id) = 1,
   INPUT_FMT(INPUT_MODE(MANY2ONE)),
   FUNC_PARAMS( WARPPATH(2) )
);

TD_DTW Output with WARPPATH(2)

id ROW_I WarpDistance WarpX_I WarpY_I
----------- -------------------- ---------------------- -------- --------
1 0 5.00000000000000E-001 19/01/01 01/01/01
1 1 1.00000000000000E 000 19/01/02 01/01/01
1 2 1.50000000000000E 000 19/01/03 01/01/02
1 3 2.00000000000000E 000 19/01/04 01/01/03
1 4 3.50000000000000E 000 19/01/05 01/01/03
2 0 1.00000000000000E 000 20/01/01 01/01/01
2 1 1.00000000000000E 000 20/01/02 01/01/01
2 2 1.00000000000000E 000 20/01/03 01/01/02
2 3 1.00000000000000E 000 20/01/04 01/01/03
2 4 2.00000000000000E 000 20/01/05 01/01/03

Example: TD_DTW Call with WARPPATH(3)

EXECUTE FUNCTION TD_DTW(
   SERIES_SPEC(TABLE_NAME(dtw_t1), ROW_AXIS(TIMECODE(seq)), SERIES_ID(id),
      PAYLOAD(FIELDS(v),CONTENT(REAL))),
   SERIES_SPEC(TABLE_NAME(dtw_t2), ROW_AXIS(TIMECODE(seq)), SERIES_ID(id),
      PAYLOAD(FIELDS(v),CONTENT(REAL)))WHERE (id) = 1,
   INPUT_FMT(INPUT_MODE(MANY2ONE)),
   FUNC_PARAMS( WARPPATH(3) )
);

TD_DTW Output with WARPPATH(3)

id ROW_I WarpDistance WarpX WarpY WarpX_I WarpY_I
----------- -------------------- ---------------------- -------------------- -------------------- -------- --------
1 0 5.00000000000000E-001 0 0 19/01/01 01/01/01
1 1 1.00000000000000E 000 1 0 19/01/02 01/01/01
1 2 1.50000000000000E 000 2 1 19/01/03 01/01/02
1 3 2.00000000000000E 000 3 2 19/01/04 01/01/03
1 4 3.50000000000000E 000 4 2 19/01/05 01/01/03
2 0 1.00000000000000E 000 0 0 20/01/01 01/01/01
2 1 1.00000000000000E 000 1 0 20/01/02 01/01/01
2 2 1.00000000000000E 000 2 1 20/01/03 01/01/02
2 3 1.00000000000000E 000 3 2 20/01/04 01/01/03
2 4 2.00000000000000E 000 4 2 20/01/05 01/01/03

Example: TD_DTW Call with DISTANCE('binary')

EXECUTE FUNCTION TD_DTW(
   SERIES_SPEC(TABLE_NAME(dtw_t1), ROW_AXIS(TIMECODE(seq)), SERIES_ID(id),
      PAYLOAD(FIELDS(v), CONTENT(REAL))),
   SERIES_SPEC(TABLE_NAME(dtw_t2), ROW_AXIS(TIMECODE(seq)), SERIES_ID(id),
      PAYLOAD(FIELDS(v), CONTENT(REAL))) WHERE (id) = 1,
   INPUT_FMT(INPUT_MODE(MANY2ONE)),
   FUNC_PARAMS( DISTANCE('binary') )
);

TD_DTW Output with DISTANCE('binary')

id ROW_I WarpDistance
----------- -------------------- ----------------------
1 0 5.00000000000000E 000
2 0 2.00000000000000E 000

Example: TD_DTW Call with RADIUS('1')

EXECUTE FUNCTION TD_DTW(
   SERIES_SPEC(TABLE_NAME(dtw_t1),ROW_AXIS(TIMECODE(seq)), SERIES_ID(id),
      PAYLOAD(FIELDS(v), CONTENT(REAL))),
   SERIES_SPEC(TABLE_NAME(dtw_t2),ROW_AXIS(TIMECODE(seq)), SERIES_ID(id),
      PAYLOAD(FIELDS(v), CONTENT(REAL))) WHERE (id) = 1,
   INPUT_FMT(INPUT_MODE(MANY2ONE)),
   FUNC_PARAMS(RADIUS('1'))
);

TD_DTW Output with RADIUS('1')

id                  ROW_I            WarpDistance
----------  --------------------  ----------------------
1                     0   3.50000000000000E 000
2                     0   2.00000000000000E 000