snr | R Documentation |
Compute the SNR for a given signal and noise power spectral density.
snr(x, psd, two.sided = FALSE)
x |
the signal waveform, a time series ( |
psd |
the noise power spectral density. May be a vector of
appropriate length ( |
two.sided |
a |
For a signal s(t), the complex-valued discrete Fourier transform s(f) is computed along the Fourier frequencies f[j]=j/(N*delta_t) | j=0,...,N/2+1, where N is the sample size, and delta_t is the sampling interval. The SNR, as a measure of "signal strength" relative to the noise, then is given by
rho=sqrt(sum(abs(s(f))^2 / ((N/(4*delta_t)) * S1(f))),
where S1(f) is the noise's one-sided power spectral density. For more on its interpretation, see e.g. Sec. II.C.4 in the reference below.
The SNR rho.
Christian Roever, christian.roever@med.uni-goettingen.de
Roever, C. A Student-t based filter for robust signal detection. Physical Review D, 84(12):122004, 2011. doi: 10.1103/PhysRevD.84.122004. See also arXiv preprint 1109.0442.
matchedfilter
, studenttfilter
# sample size and sampling resolution: N <- 1000 deltaT <- 0.001 # For the coloured noise, use some AR(1) process; # AR noise process parameters: sigmaAR <- 1.0 phiAR <- 0.9 # generate non-white noise # (autoregressive AR(1) low-frequency noise): noiseSample <- rnorm(10*N) for (i in 2:length(noiseSample)) noiseSample[i] <- phiAR*noiseSample[i-1] + noiseSample[i] noiseSample <- ts(noiseSample, deltat=deltaT) # estimate the noise spectrum: PSDestimate <- welchPSD(noiseSample, seglength=1, windowingPsdCorrection=FALSE) # generate a (sine-Gaussian) signal: t0 <- 0.6 phase <- 1.0 t <- ts((0:(N-1))*deltaT, deltat=deltaT, start=0) signal <- exp(-(t-t0)^2/(2*0.01^2)) * sin(2*pi*150*(t-t0)+phase) plot(signal) # compute the signal's SNR: snr(signal, psd=PSDestimate$power)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.