Title: | Integral of B-Spline Functions |
---|---|
Description: | Calculate B-spline basis functions with a given set of knots and order, or a B-spline function with a given set of knots and order and set of de Boor points (coefficients), or the integral of a B-spline function. |
Authors: | Feng Chen |
Maintainer: | Feng Chen <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.4 |
Built: | 2025-01-10 05:19:02 UTC |
Source: | https://github.com/cran/ibs |
Evaluate the integral of a B-spline function, or the B-spline function itself, or the B-spline basis functions.
The function bsbases
calculates the values of the B-spline basis
functions defined by knots knots
and order ord
at sites
x
. The function bspline
evaluates the B-spline function
defined by knots knots
, order ord
, and coefficients
coef
at sites x
. The function ibs
calculates the
integrals of the B-spline function defined by knots knots
,
order ord
, and coefficients coef
from the smallest knot
to each of the values in x
.
Creator: Feng Chen
Maintainer: Feng Chen <[email protected]>
de Boor, C. (2001) A Practical Guide to Splines. Revised Edition. Springer: New York.
Evaluate the B-spline basis function at the x
value(s).
bsbases(x, knots, ord)
bsbases(x, knots, ord)
x |
Numerical value or vector. The value(s) at which to evaluate the B spline bases. |
knots |
Numerical vector. The knot positions/sites of the B-spline bases. |
ord |
An integer >=1. The order of the B-spline bases. Equals degree plus 1. |
A numerical matrix of length(x)
rows and
length(knots)-ord
columns.
In contrast to the implementation based on the splineDesign
function from the splines
package, this version of the B-spline
basis functions are left-continuous at the rightmost knot.
Feng Chen <[email protected]>
de Boor, C. (2001) A Practical Guide to Splines. Revised Edition. Springer: New York.
kns <- c(rep(0,4),1:4*0.2,rep(1,4)) round(bsbases(0:5/5,kns,2),10) round(splines::splineDesign(kns,0:5/5,2),10)
kns <- c(rep(0,4),1:4*0.2,rep(1,4)) round(bsbases(0:5/5,kns,2),10) round(splines::splineDesign(kns,0:5/5,2),10)
Evaluate the value of the B-spline function with knots knots
,
order ord
, and coefficients coef
at value(s) x
.
bspline(x, knots, ord, coef = rep(1, length(knots) - ord))
bspline(x, knots, ord, coef = rep(1, length(knots) - ord))
x |
Numerical value or vector. The value(s) at which to evaluate the B-spline. |
knots |
Numerical vector. The knot positions/sites of the B-spline function. |
ord |
An integer >=1. The order of the B-spline function. Equals degree plus 1. |
coef |
A numerical vector. The coefficients (de Boor points) defining the B-spline function. |
A scalar or a vector of length equal to that of x
.
In contrast to the implementation based on the splineDesign
function from the splines
package, this version of the B-spline
function is left-continuous at the rightmost knot site.
Feng Chen <[email protected]>
de Boor, C. (2001) A Practical Guide to Splines. Revised Edition. Springer: New York.
kns <- c(rep(0,4),1:4*0.2,rep(1,4)) bspline(0:10/10,kns,3,rep(1,length(kns)-3)) splines::splineDesign(kns,0:10/10,3)%*%rep(1,length(kns)-3)
kns <- c(rep(0,4),1:4*0.2,rep(1,4)) bspline(0:10/10,kns,3,rep(1,length(kns)-3)) splines::splineDesign(kns,0:10/10,3)%*%rep(1,length(kns)-3)
Calculate the integral of a B-spline function.
ibs(x, knots, ord=4, coef = rep(1, length(knots) - ord))
ibs(x, knots, ord=4, coef = rep(1, length(knots) - ord))
x |
Numerical value or vector. The value(s) at which to evaluate the
integral of the B-spline; must be in the interval bewteen the
smallest knot to the |
knots |
Numerical vector. The knot positions/sites of the B-spline function to be integrated. |
ord |
An integer >=1. The order of the B-spline integrand function to be integrated. Equals degree plus 1. |
coef |
A numerical vector. The coefficients (de Boor points) defining the B-spline integrand function. |
The function returns the integral(s) of the B-spline function
specified by knots knots
, order ord
, and coefficients
coef
, from the minimum knot position to each x
value. The evaluation is based on a closed form expression of the
integral in terms of higher order B-splines, given on page 128 of de
Boor (2001).
A numerical equal to the integral(s).
Feng Chen <[email protected]>
de Boor, C (2001) A Practical Guide to Splines. Revised Edition. Springer: New York.
kns <- c(rep(0,4),1:4*0.2,rep(1,4)) co <- rnorm(length(kns)-3) integrate(bspline,knots=kns,ord=3,coef=co,0,0.95) integrate(function(x)bsbases(x,kns,3) %*% co,0,0.95) ibs(0.95,kns,3,co)
kns <- c(rep(0,4),1:4*0.2,rep(1,4)) co <- rnorm(length(kns)-3) integrate(bspline,knots=kns,ord=3,coef=co,0,0.95) integrate(function(x)bsbases(x,kns,3) %*% co,0,0.95) ibs(0.95,kns,3,co)