Correlation
Measure similarity between signals for pattern matching and analysis.
Cross-Correlation
$$ (x \star y)[n] = \sum_{k=-\infty}^{\infty} x[k] y[n + k] $$
Auto-Correlation
$$ R_{xx}[n] = (x \star x)[n] = \sum_{k=-\infty}^{\infty} x[k] x[n + k] $$
Implementation
1import numpy as np
2
3# Cross-correlation
4corr = np.correlate(x, y, mode='full')
5
6# Auto-correlation
7autocorr = np.correlate(x, x, mode='full')
8
9# Normalized cross-correlation
10def normalized_xcorr(x, y):
11 corr = np.correlate(x, y, mode='full')
12 norm = np.sqrt(np.sum(x**2) * np.sum(y**2))
13 return corr / norm
Applications
- Pattern matching: Find template in signal
- Time delay estimation: Find lag between signals
- Pitch detection: Find fundamental frequency
Further Reading
Related Snippets
- Convolution
Linear systems and filtering operations - Fourier Transform
DFT, FFT, and frequency analysis - Laplace Transform
S-domain analysis and transfer functions - Sampling Theory
Nyquist theorem, reconstruction, and interpolation - Signal Theory Basics
Fundamental concepts in signal processing - Window Functions
Spectral leakage reduction for FFT analysis