Skip to contents

Random Spline Density.

Usage

rSplineDensity(knots,
               nx = 200L,
               nKnots = 10L,
               xmin = 0.0, xmax = 1.0,
               order = 4L, plot = TRUE)

Arguments

knots

Numeric vector of knots, given in increasing order.

nx

Number of default evaluation points.

nKnots

Number of knots if knots is not given.

xmin

Lower end-point of the density.

xmax

Upper end-point of the density.

order

Order of the spline, i.e. the degree of the polynomial pieces minus one. With ord = 2 one gets a broken line spline and ord = 4 leads to a cubic spline.

plot

Logical. If TRUE a plot is shown.

Value

An object of class "SplineDensity".

Details

From the sequence of knots and the order, a basis of B-splines is built. A vector of positive random coefficients is drawn and suitably normalized to ensure that the spline integrates to one on the support.

Author

Yves Deville

Examples

set.seed(1234)
SD <- rSplineDensity(order = 4, xmax = 10)
#> Warning: Recycling array of length 1 in vector-array arithmetic is deprecated.
#>   Use c() or as.vector() instead.
plot(SD, main = "spline density")

#> NULL
## uniform knots sequence
SDu <- rSplineDensity(order = 4, knots = 0:10)
#> Warning: Recycling array of length 1 in vector-array arithmetic is deprecated.
#>   Use c() or as.vector() instead.
plot(SDu, main = "spline density with uniform knots sequence.")

#> NULL