I'm wondering if anyone knows of a fast (i.e. O(N log(N)) ) method of calculating the average square difference function (ASDF) or average magnitude difference function (AMDF) for a periodic signal, or it is even possible.
I know that one can use the FFT to calculate the periodic cross correlation. For example, in Matlab code,
for i=1:N
xc(i)=sum(x1*circshift(x2,i-1));
end
is equivalent to the much faster
xc=ifft(fft(x1).*conj(fft(x2));
Is there a similar "fast" algorithm for
for i=1:N
ASDF(i)=sum((x1-circshift(x2,i-1)).^2)/N;
end
or
for i=1:N
AMDF(i)=sum(abs(x1-circshift(x2,i-1)))/N;
end
?
You can expand your definition of ASDF as follows:
for i = 1:N
asdf(i) = (sum(x1.^2) - 2*sum(x1*circshift(x2,i-1)) + sum(x2.^2))/N;
end
which simplifies to
asdf = (-2*ifft(fft(x1).*conj(fft(x2))) + sum(x1.^2) + sum(x2.^2))/N;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With