Skip to contents

Mirrors the C# Fourier.Correlation: an FFT-based correlation, NOT a normalized correlation coefficient (see correlation() for that). Both series must have the same power-of-two length.

Usage

cross_correlation(x, y)

Arguments

x, y

numeric vectors of equal, power-of-two length.

Value

a numeric vector in wraparound order: increasing positive lags in [1] up to [n/2], increasing negative lags in [n] down to [n/2 + 1].

Examples

cross_correlation(c(1, 2, 3, 4), c(4, 3, 2, 1))
#> [1] 20 26 28 26