I have recently started using Mathdotnet Numerics statistical package to do data analysis in c#.
I am looking for the cross correlation function. Does Mathdotnet hav
I have tried the above solution with a sine wave that was shifted backwards by 20 time units with respect to a first sine wave. It gave me the correct result that the maximum of the correlation is at -20 (see below). One could discuss whether its appropriate to apply a zero padding, the zeros are not usually part of the signal. The MATLAB cross-correlation is not normalized the same way, it's not a "Pearson correlation" as in the example above.
The definition of the MATLAB cross-correlation is different: for scaling option "none" its a convolution with the time reversed signal. There are also various scaling options but none of them gives the same result as the Pearson correlation: matlab definition of xcorr
My result: cross correlation of sin(n*0.1)
with sin(n*0.1 - 20*0.1)
using the example above: