A faster findsignal method

6 Ansichten (letzte 30 Tage)
Matt Flax
Matt Flax am 17 Okt. 2021
Kommentiert: Matt Flax am 20 Okt. 2021
findsignal implements a method for finding the best similairty between two signals. findsignal is slow.
Is there a faster way to execute findsignal ?
  2 Kommentare
Eamonn
Eamonn am 20 Okt. 2021
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 am 20 Okt. 2021
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 !

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Walter Roberson
Walter Roberson am 17 Okt. 2021
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 am 17 Okt. 2021
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

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by