Hi,

I am new to Math.Net. It’s really a fantastic tool.

Could you give me any suggestions about this situation? This takes around 20 second to get the result.

signal size: 20000

pattern size: 10000

I am trying to find the max correlation and its shift for the pattern in the signal. The approach is as following:

```
private KeyValuePair<int, double> findMaxCorrelation(List<double> pattern, List<double> signal)
{
int MaxShift = 0;
double MaxCorrelation = .0;
int patternLength = pattern.Count;
int signalLength = signal.Count;
int compensatedSignalLength = signalLength + 2 * patternLength;
// signal 111111
// patern 0000
// compensatedsignal 00001111110000
// add size of the signal to ensure the signal can cover the whole range of the pattern
List<double> compensatedSignal = new List<double>(signal);
compensatedSignal.InsertRange(0, Enumerable.Repeat(0.0, patternLength));
compensatedSignal.AddRange(Enumerable.Repeat(0.0, patternLength));
//
for (int i = 0; i < signalLength + patternLength + 1; i++)
{
double correlation = MathNet.Numerics.Statistics.Correlation.Pearson(pattern, compensatedSignal.Where((v, idx) => (idx >= i && idx < i + patternLength)));
if (correlation > MaxCorrelation)
{
MaxCorrelation = correlation;
MaxShift = i - patternLength;
}
}
return new KeyValuePair<int, double>(MaxShift, MaxCorrelation);
}
```