RunningCor: Fast Running Correlation Computation

Description Usage Arguments Details Value Examples

Description

Computes running correlation between two sequences in a fixed width window, whose length corresponds to the length of the shorter sequence. Uses convolution via Fast Fourier Transform.

Usage

1
RunningCor(x, y, circular = FALSE)

Arguments

x

A numeric vector.

y

A numeric vector, of equal or shorter length than x sequence.

circular

logical; whether running correlation is computed assuming circular nature of x sequence (see Details).

Details

Computes running correlation between two sequences in a fixed width window. The length of a window is equal to the shorter of the two sequences (y), and window "runs" over the length of longer sequence (x).

The length of output vector equals the length of x vector. Parameter circular determines whether x sequence is assumed to have a circular nature. Assume l_x is the length of sequence x, l_y is the length of shorter sequence y.

If circular equals TRUE then

If circular equals FALSE then

Value

A numeric vector.

Examples

1
2
3
4
5
x <- sin(seq(0, 1, length.out = 1000) * 2 * pi * 6)
y <- x[1:100]
out1 <- RunningCor(x, y, circular = TRUE)
out2 <- RunningCor(x, y, circular = FALSE)
plot(out1, type = "l"); points(out2, col = "red")

martakarass/convo documentation built on May 16, 2019, 11:08 a.m.