MeanSpectrum | R Documentation |
Calculate the mean spectrum from a list of individual spectra including weighting of the individual spectra and, if needed, interpolation to the highest resolution frequency grid. The default weighting produces the simple arithmetic mean. Interpolation is only performed when the frequency axes of the individual spectra have different lengths and/or differ in frequency discretization.
MeanSpectrum(specList, iRemoveLowest = 1, weights = rep(1, length(specList)))
specList |
list of spectra, i.e. objects of class |
iRemoveLowest |
integer; number of lowest frequencies to remove from each individual spectral estimate (e.g. to remove detrending bias) prior to the interpolation and averaging. |
weights |
numeric vector of weights; its length must match the number of
elements in |
object of class "spec"
with the weighted mean spectrum,
amended by the element nRecord
which gives the number of records
contributing to each mean spectral estimate.
Thomas Laepple and Thomas Münch
# Simple arithmetic average
f1 <- 1 : 5
f2 <- f1
s1 <- rep(1, length(f1))
s2 <- rep(3, length(f2))
dof1 <- rep(1, length(f1))
dof2 <- rep(1, length(f2))
spectra <- list(list(freq = f1, spec = s1, dof = dof1),
list(freq = f2, spec = s2, dof = dof2))
MeanSpectrum(spectra, iRemoveLowest = 0)
# Weighted mean with interpolation
f1 <- 1 : 5
f2 <- 3 : 8
s1 <- rep(1, length(f1))
s2 <- rep(3, length(f2))
dof1 <- rep(1, length(f1))
dof2 <- rep(1, length(f2))
spectra <- list(list(freq = f1, spec = s1, dof = dof1),
list(freq = f2, spec = s2, dof = dof2))
MeanSpectrum(spectra, iRemoveLowest = 0, weights = c(1, 2))
# with some detrending bias removal
MeanSpectrum(spectra, iRemoveLowest = 1, weights = c(1, 2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.