0
0
RosConceptBeginner · 3 min read

Autocorrelation in Signal Processing: Definition and Examples

In signal processing, autocorrelation measures how similar a signal is to a delayed version of itself over time. It helps identify repeating patterns or periodic signals by comparing the signal with shifted copies of itself.
⚙️

How It Works

Imagine you have a song and you want to find if a certain beat repeats regularly. Autocorrelation works like sliding a copy of the song over itself and checking how well the beats match at each slide. When the beats line up well, the autocorrelation value is high.

This process involves multiplying the signal by a shifted version of itself and summing the results. If the signal has a repeating pattern, the autocorrelation will show peaks at delays matching the pattern's period. If the signal is random noise, the autocorrelation will be low except at zero delay.

💻

Example

This example shows how to calculate and plot the autocorrelation of a simple repeating signal using Python.

python
import numpy as np
import matplotlib.pyplot as plt

# Create a simple repeating signal: a sine wave
fs = 100  # sampling frequency
f = 5     # frequency of sine wave
t = np.arange(0, 1, 1/fs)
signal = np.sin(2 * np.pi * f * t)

# Calculate autocorrelation using numpy.correlate
autocorr = np.correlate(signal, signal, mode='full')
# Keep only the second half (positive lags)
autocorr = autocorr[autocorr.size // 2:]

# Plot the signal and its autocorrelation
plt.figure(figsize=(10,4))
plt.subplot(1,2,1)
plt.plot(t, signal)
plt.title('Original Signal')
plt.xlabel('Time (s)')

plt.subplot(1,2,2)
lags = np.arange(0, len(autocorr)) / fs
plt.plot(lags, autocorr)
plt.title('Autocorrelation')
plt.xlabel('Lag (s)')
plt.tight_layout()
plt.show()
Output
A plot window showing two graphs: left graph is a sine wave signal over 1 second; right graph is the autocorrelation with peaks at multiples of 0.2 seconds (the sine wave period).
🎯

When to Use

Autocorrelation is useful when you want to find repeating patterns or periodic signals in data. For example, it helps detect the pitch in audio signals, find cycles in financial data, or analyze sensor signals for faults.

It is also used to check if a signal is random or has structure, and to estimate the fundamental frequency of a signal without needing a reference.

Key Points

  • Autocorrelation compares a signal with shifted versions of itself.
  • It reveals repeating patterns and periodicity in signals.
  • High autocorrelation values at certain delays indicate strong similarity.
  • It is widely used in audio, finance, and sensor data analysis.

Key Takeaways

Autocorrelation measures similarity of a signal with delayed copies of itself.
It helps identify repeating patterns and periodic signals.
Use autocorrelation to find cycles or pitch without external references.
High autocorrelation peaks indicate strong repeating features in the signal.