A faster findsignal method

7 ビュー (過去 30 日間)
Matt Flax
Matt Flax 2021 年 10 月 17 日
コメント済み: Matt Flax 2021 年 10 月 20 日
findsignal implements a method for finding the best similairty between two signals. findsignal is slow.
Is there a faster way to execute findsignal ?
  2 件のコメント
Eamonn
Eamonn 2021 年 10 月 20 日
You are in luck!
The MASS algorithm is much faster, and is more general
MASS supports GPUs
If you want to see case studies etc, Google "100 Time Series Data Mining Questions (with Answers!)"
Matt Flax
Matt Flax 2021 年 10 月 20 日
Nice site! The DFT method is good for longer signals.For shorter signals this is more efficient : https://au.mathworks.com/matlabcentral/fileexchange/100893-findsimilarity
I also tested your code sing gpuArray, however that significantly slows down the computation for shorter signals as well !

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2021 年 10 月 17 日
Maybe. It would not astonish me if parts if it could be rewritten to use an available GPU.
However... the algorithm already invokes two mex functions to improve performance, so you might be hard-pressed to find a more efficient algorithm.
The algorithm involves normalization of signals, and involves calculating dynamic time warping (dtw) https://www.mathworks.com/help/signal/ref/dtw.html to try to find the best match. The dtw is one of the portions done as mex.
You might be able to find a different algorithm, but you would need to ask whether it is doing the same job as findsignal() is doing. For example, some people might be satisfied with xcorr() https://www.mathworks.com/help/matlab/ref/xcorr.html but that does not have the same behaviour of trying to find the best possible place for the signals to fit together including stretching.

Matt Flax
Matt Flax 2021 年 10 月 17 日
I see, thanks for the information. Yes, xcorr will not work because it has no form of error or difference measure.
The core algorithm of interest is (the same as findsignal.m) the algorithm used in Waveform Similarity Overlap Add (WSOLA), specifically the algorithm for similarity searching : https://github.com/flatmax/gtkiostream/blob/master/src/WSOLA.C#L62
Which can be written in Matlab like so to find a similar signal to s in the vector y :
Ns=size(s,1);
res=buffer(y,Ns,Ns-1,'nodelay');
res=s-res;
errM=rms(res);
[err,nI]=min(errM);
It is interesting that when profiling the above non-mex code, it is similar in speed to the findsignal.m algorithm. The buffer code is heavy on memory allocation which is slow. The rms method is not a mex code.
It would seem that there is possibly scope to improve the speed somewhere ?
Matt

カテゴリ

Help Center および File ExchangeCorrelation and Convolution についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by