Skip to contents

Welch's averaged periodogram PSD: split into segments, window (Hanning), periodogram each, average. Delegates to oce::pwelch() if available, otherwise computes a Hanning-windowed, 50%-overlap implementation in base R.

Usage

welch(x, fs, nperseg = 256L)

Arguments

x

Numeric vector (1-D signal).

fs

Sampling frequency in Hz.

nperseg

Segment length (default 256).

Value

List with filtered (PSD), name, fs, n_samples, and extra (freqs).

Details

Reference: Welch, P.D. (1967) "The use of fast Fourier transform for the estimation of power spectra", IEEE Trans. Audio Electroacoust. AU-15(2):70–73.

Examples

# \donttest{
set.seed(1)
t <- seq(0, 1, length.out = 1024)
x <- sin(2 * pi * 50 * t) + 0.3 * rnorm(length(t))
res <- welch(x, fs = 1024)
length(res$filtered)
#> [1] 129
# }