Random Spline Density
rSplineDensity.Rd
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 andord = 4
leads to a cubic spline. - plot
-
Logical. If
TRUE
a plot is shown.
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.
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