ncint: Newton-Cotes timeseries integration

Description Usage Arguments Value Examples

View source: R/ncint.R

Description

Integrate a timeseries using stable Newton-Cotes filters.

Usage

1
ncint(s, order = 2, deltat = 1, nfac = 1)

Arguments

s

timeseries

order

Newton-Cotes filter order ( 2 <= order <= 7 ). Beware that high-frequence content can become unstable for orders > 2 (order = 2 is the trapezoid rule).

deltat

sampling interval; used only if s is not a "ts" object. Defaults to 1.

nfac

oversampling factor. Must be integer >= 1. Timeseries s is resampled at sampling interval deltat/nfac prior to integration. Does not affect timing or duration of returned integrated series. nfac > 1 provides greater accuracy for timeseries with energetic high frequency components.

Value

For s(t0 + i*deltat) for 0 <= i < length( s ), returns the definite integral from t0 to t0 + i*deltat. This is equivalent to the indefinite integral of s with an arbitrary baseline.

Examples

1
2
3
4
5
6
7
t <- 1:200
s <- sin( 2 * pi * t / 20 )
ints.true <- -cos( 2 * pi * t / 20 ) / ( 2 * pi / 20 )
ints <- ncint( s, order = 2, deltat = 1 )
offset <- ints.true[1] - ints[1]
plot( t, ints.true, type = "l" )
lines( t, ints + offset, col = "red" )

jrevenaugh/TSAUMN documentation built on Nov. 8, 2019, 2:20 p.m.