integral.dierckx {DierckxSpline} | R Documentation |
Calculates the integral of a spline function s(x) of degree k, which is given in its normalized b-spline representation
## S3 method for class 'dierckx': integral(expr, from = NULL, to = NULL, ...)
expr |
An object of class dierckx . |
from |
Lower integration bound. If NULL , the minimum knot
value is used. |
to |
Upper integration bound. If NULL , the maximum knot
value is used. |
... |
ignored |
s(x)
is considered to be identically zero outside the interval
(t(k+1),t(n-k))
, where t
are the knot values. For this reason,
from
and to
are forced to be in or on the boundaries of
the knots.
The value of the integral.
Sundar Dorai-Raj with help from William Venables on how to eliminate a
conflict between the generic integral
functions in the
PolynomF
and DierckxSpline
packages.
Dierckx, P. (1991) Curve and Surface Fitting with Splines, Oxford Science Publications.
integral
,
curfit
,
deriv.dierckx
,
spline
,
smooth.spline
x <- seq(0, 1, 0.1) y <- (1 - x)^3 z <- curfit(x, y, knots = seq(0, 1, 0.2)) plot(x, y, type = "p") lines(x, fitted(z), col = "blue") (answer <- integrate(function(x) (1 - x)^3, 0, 1)) #0.25 with absolute error < 2.8e-15 integral(z)-answer$value # 0 (ans2 <- integrate(function(x) (1 - x)^3, 0.5, 0.6)) #0.009225 with absolute error < 1.0e-16 integral(z, 0.5, 0.6)-ans2$value # 6e-9