View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Martin Brown Martin Brown is offline
external usenet poster
 
Posts: 230
Default faster way to do this?

Matt S wrote:
This looks like the sort of correlation problem that is best done in the
Fourier domain - particularly so if the reference spectra are contant.
Then you get the entire correlation at every shift with a cost 2NlogN
transform and some book keeping where N is the length of your array.


Martin, can you explain further what you mean when you say it should be in
the Fourier domain? Can you give me some references?


A convolution with a shift in real space is a (complex number)
multiplication in the Fourier domain. The best way depends critically on
the lengths of the data and pattern to be matched. For large datasets
the FFT method will usually win by a huge margin.

There should be plenty of references online and practical but slightly
dodgy code to do it on the Numerical Recipes webpage (old edition is
free access).

http://www.nrbook.com/a/bookcpdf/c13-2.pdf

And you get every correlation result in a single complicated operation.

You probably need to read the descriptions of FFTs and their version is
restricted to power of two length arrays (and you will need to think
about the boundary conditions you wish to impose).

Worth asking in the numerical analysis group too.

They will be rude about NR methods but their algorithms are (mostly)
usable just not always the best.

Regards,
Martin Brown