Title: | Computation of a Cubic B-Spline Basis and Its Derivatives |
---|---|
Description: | Computation of a cubic B-spline basis for arbitrary knots. It also provides the 1st and 2nd derivatives, as well as the integral of the basis elements. It is used by the author to fit penalized B-spline models, see e.g. Jullion, A. and Lambert, P. (2006) <doi:10.1016/j.csda.2006.09.027>, Lambert, P. and Eilers, P.H.C. (2009) <doi:10.1016/j.csda.2008.11.022> and, more recently, Lambert, P. (2021) <doi:10.1016/j.csda.2021.107250>. It is inspired by the algorithm developed by de Boor, C. (1977) <doi:10.1137/0714026>. |
Authors: | Philippe Lambert [aut, cre] (Université de Liège / Université catholique de Louvain (Belgium)) |
Maintainer: | Philippe Lambert <[email protected]> |
License: | GPL-3 |
Version: | 1.0.0 |
Built: | 2024-11-19 05:25:01 UTC |
Source: | https://github.com/plambertuliege/cubicbsplines |
Computation of a cubic B-spline basis associated to a given vector of knots
Bsplines(x, knots)
Bsplines(x, knots)
x |
vector of values where the B-spline basis must be evaluated. |
knots |
vector of knots spanning the desired B-spline basis. |
A matrix of dimension length(x)
by (length(knots)+2)
.
Each column of the matrix corresponds to one cubic B-spline in the basis.
Bsplines(x=runif(20),knots=seq(0,1,length=11))
Bsplines(x=runif(20),knots=seq(0,1,length=11))
Computation of the 1st derivative of a cubic B-spline basis associated to a given vector of knots
D1Bsplines(x, knots)
D1Bsplines(x, knots)
x |
vector of values where the 1st derivative of the B-spline basis must be evaluated. |
knots |
vector of knots spanning the desired B-spline basis. |
A matrix of dimension length(x)
by (length(knots)+2)
.
Each column corresponds to (the 1st derivative of) one cubic B-spline in the basis.
D1Bsplines(x=runif(20),knots=seq(0,1,length=11))
D1Bsplines(x=runif(20),knots=seq(0,1,length=11))
Computation of the 2nd derivative of a cubic B-spline basis associated to a given vector of knots
D2Bsplines(x, knots)
D2Bsplines(x, knots)
x |
vector of values where the 2nd derivative of the B-spline basis must be evaluated. |
knots |
vector of knots spanning the desired B-spline basis. |
A matrix of dimension length(x)
by (length(knots)+2)
.
Each column of the matrix corresponds to (the 2nd derivative of) one cubic B-spline in the basis.
D2Bsplines(x=runif(20),knots=seq(0,1,length=11))
D2Bsplines(x=runif(20),knots=seq(0,1,length=11))
Computation of the integral of a cubic B-spline basis over (t0,x) for a given vector of knots
IBsplines(t0, x, knots)
IBsplines(t0, x, knots)
t0 |
scalar giving lower value of the integration interval. |
x |
vector giving the upper values of the integration interval. |
knots |
vector of knots spanning the desired B-spline basis. |
A matrix of dimension length(x)
by (length(knots)+2)
.
Each integrated cubic B-spline is within a given column.
IBsplines(t0=0,x=runif(20),knots=seq(0,1,length=11))
IBsplines(t0=0,x=runif(20),knots=seq(0,1,length=11))
Trapeze integration from a vector of function values evaluated at quadrature points
trapeze(x, fx)
trapeze(x, fx)
x |
grid of values for the quadrature (vector). |
fx |
values of the function on the grid (vector). |
vector with a numerical approximation of on the grid using the trapeze method.
x = seq(-4,2,length=100) ; fx = dnorm(x) ; res = trapeze(x,fx) cbind(true=pnorm(x),trapeze=res)
x = seq(-4,2,length=100) ; fx = dnorm(x) ; res = trapeze(x,fx) cbind(true=pnorm(x),trapeze=res)