How to get pairwise distance matrices from dynamic time warping dtw on a matrix of time series ?

조회 수: 6 (최근 30일)
I have a matrix (1018 x 3744) where each column is a timeseries. The timestamps, which are the same for each row, are in a separete vector. Some of the time series contain NaN values at a variety of time points (rows).
1) If there are no NaNs, How can I generate pairwise distance matrices for all of the time series using the dynamic time warping function? I know how to do it for a single pair of time series vectors but not for all of the pairwise combinations in this matrix.
2) How can I do this if there are NaNs?
A subsample of the matrix (the first 10 columns is attached).
Thanks!

답변 (1개)

Greg Dionne
Greg Dionne 2019년 5월 2일
Your signals look extremely well time-aligned (within a sample).
Since you have NaN, I suppose you could just perform a weighted comparison over the points you currently have. Maybe something like:
function D = mdist(X)
n = size(X,2);
D = zeros(n);
for i=1:n
for j=i+1:n
idx = isfinite(X(:,i))&isfinite(X(:,j));
D(i,j) = rms(X(idx,i)-X(idx,j));
end
end
D = D+D';
>> mdist(subset)
ans =
0 0.0002 0.0005 0.0009 0.0015 0.0022 0.0030 0.0039 0.0049 0.0059
0.0002 0 0.0003 0.0008 0.0013 0.0021 0.0029 0.0038 0.0047 0.0058
0.0005 0.0003 0 0.0005 0.0010 0.0018 0.0026 0.0035 0.0044 0.0055
0.0009 0.0008 0.0005 0 0.0006 0.0013 0.0021 0.0030 0.0040 0.0051
0.0015 0.0013 0.0010 0.0006 0 0.0007 0.0015 0.0024 0.0034 0.0045
0.0022 0.0021 0.0018 0.0013 0.0007 0 0.0008 0.0017 0.0027 0.0038
0.0030 0.0029 0.0026 0.0021 0.0015 0.0008 0 0.0009 0.0019 0.0030
0.0039 0.0038 0.0035 0.0030 0.0024 0.0017 0.0009 0 0.0010 0.0021
0.0049 0.0047 0.0044 0.0040 0.0034 0.0027 0.0019 0.0010 0 0.0011
0.0059 0.0058 0.0055 0.0051 0.0045 0.0038 0.0030 0.0021 0.0011 0
  댓글 수: 1
Joel Singley
Joel Singley 2019년 5월 6일
Thanks, I'll give this a try. There are quite a few time periods were the time series (especially those not in the sample) diverge from each other, so they are not always so well aligned.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by