rspl: Simulate random cubic splines

rsplR Documentation

Simulate random cubic splines

Description

Simulate random cubic splines.

Usage

rspl(x, domain = NULL, n = 1)

Arguments

x

x-values where simulated cubic splines are evaluated.

domain

a vector of two values giving domain interval [a, b]. Will use min(x) and max(x) if not specified.

n

number of replicates to simulate.

Value

A list of four components:

  • y is a vector of random cubic spline values evaluated at x when n = 1, or a matrix of n columns when n > 1, where each column is an independent replicate of random cubic splines;

  • b is a vector of random B-spline coefficients when n = 1, or a matrix of n columns when n > 1, where each column is an independent replicate of random B-spline coefficients;

  • xt is the full knot sequence for B-splines;

  • domain gives the domain of the simulated spline(s).

Author(s)

Zheyuan Li zheyuan.li@bath.edu

Examples

require(gps)

x <- seq.int(0, 1, 0.01)

## a random cubic spline
y <- rspl(x, n = 1)$y
op <- par(mar = c(2, 2, 1.5, 0.5))
plot(x, y, type = "l", ann = FALSE)
title("a random cubic spline")
par(op)

## 5 random cubic splines
Y <- rspl(x, n = 5)$y
op <- par(mar = c(2, 2, 1.5, 0.5))
matplot(x, Y, type = "l", lty = 1, ylab = "y")
title("5 random cubic splines")
par(op)

gps documentation built on Nov. 2, 2023, 6:08 p.m.

Related to rspl in gps...