Description Usage Arguments Value Author(s) See Also Examples
View source: R/smooth.average.R
the weight of previous elements is determined by the resolution of the time series and the half-life of the weighting function
1  | smooth.average(amplitude, time.res, half.life, initial.value = 1)
 | 
amplitude | 
 a vector of real-valued numbers  | 
time.res | 
 the time interval separating the elements of   | 
half.life | 
 the time it takes for half of an element's impact to disappear.  | 
initial.value | 
 the starting value of the smooth. it's usually good to start with
something other than   | 
a numeric vector the same length as amplitude
Benjamin N. Taft ben.taft@landmarkacoustics.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16  | ##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.
## The function is currently defined as
function (amplitude, time.res, half.life, initial.value = 1) 
{
    N <- length(amplitude)
    smooth.amplitude <- rep(initial.value, N)
    k <- time.res/half.life
    for (i in 2:N) {
        smooth.amplitude[i] <- (1 - k) * smooth.amplitude[i - 
            1] + k * amplitude[i]
    }
    return(invisible(smooth.amplitude))
  }
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.