Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tutorial on Autocorrelation? [closed]

Ive recently been considering using Autocorrelation for Pitch Detection. However, I am finding it difficult on finding good sources of where to learn autocorrelation, by this I mean sources that make it easy to understand autocorrelation step-by-step.

Im not that very good a programmer yet and also not really big on formulas so the sources that I find are really difficult to understand.

Basically, what I know now is the concept of autocorrelation is like a compare-and-contrast method of a signal? But I would really appreciate it if I can have more understanding of the autocorrelation algorithm.

Thank you very much!

UPDATE: Here is a sample code I got from a site. Maybe you can use it as reference. Ive tested this code and it does return the correct pitch properly (albeit there are some incorrect ones here and there)

maxOffset = sampleRate / minFreq;
minOffset = sampleRate / maxFreq;

for (int lag = maxOffset; lag >= minOffset; lag--)
{
   float corr = 0; // this is calculated as the sum of squares
   for (int i = 0; i < framesize; i++)
   {
      int oldIndex = i - lag;
      float sample = ((oldIndex < 0) ? prevBuffer[frames + oldIndex] : buffer[oldIndex]);
      corr += (sample * buffer[i]);
   }

   if (corr > maxCorr)
   {
      maxCorr = corr;
      maxLag = lag;
   }
}

return sampleRate / maxLag;
like image 709
user488792 Avatar asked Jul 23 '11 12:07

user488792


People also ask

How do you explain autocorrelation?

Autocorrelation represents the degree of similarity between a given time series and a lagged version of itself over successive time intervals. Autocorrelation measures the relationship between a variable's current value and its past values.

Why is autocorrelation important in time series?

Autocorrelation is also known as serial correlation, time series correlation and lagged correlation. Regardless of how it's being used, autocorrelation is an ideal method for uncovering trends and patterns in time series data that would have otherwise gone undiscovered.

Why is autocorrelation a problem in regression?

Autocorrelation can cause problems in conventional analyses (such as ordinary least squares regression) that assume independence of observations. In a regression analysis, autocorrelation of the regression residuals can also occur if the model is incorrectly specified.


1 Answers

Here's what I hope is a simple explanation.

Firstly consider how sonar works - you send out a known signal and then compare a received signal with the original - the signals are compared over a range of possible delays and the best match corresponds to the round trip time for the reflected signal.

OK - now think of a periodic signal, such as a sustained middle C note on a piano. If you compare the note with itself at a range of different delays you will get a match for any delay which corresponds to the pitch period of the note. This is essentially what autocorrelation is: comparing a signal with itself over a range of possible delays and getting a peak wherever signal matches the delayed version of itself. For most musical notes the first such peak corresponds to exactly one pitch period, and so you can deduce the pitch from this (pitch or frequency = reciprocal of delay).

like image 101
Paul R Avatar answered Oct 17 '22 04:10

Paul R