Skip to contents

Native Welch-style estimator built from windowed segment FFTs (module 20).

Usage

morie_dsp_coherence(x, y, fs = 1, nperseg = 256L)

Arguments

x

Numeric vector.

y

Numeric vector.

fs

Sampling frequency (Hz). Default 1.

nperseg

Segment length. Default 256.

Value

List with freqs and coh (magnitude squared coherence).

References

Rangayyan & Krishnan (2015), Ch. 6, sec. 6.9.

Examples

set.seed(23)
fs <- 512L
t <- seq.int(0, fs - 1L) / fs
x <- sin(2 * pi * 50 * t) + rnorm(fs, sd = 0.2)
y <- x + rnorm(fs, sd = 0.2)
out <- morie_dsp_coherence(x, y, fs = fs, nperseg = 128L)
str(out, max.level = 1)
#> List of 2
#>  $ freqs: num [1:65] 0 4 8 12 16 20 24 28 32 36 ...
#>  $ coh  : num [1:65] 0.414 0.303 0.428 0.653 0.383 ...