pcinterpolate: Interpolate a monotone function (via piecewise cubic Hermite)

Description Usage Arguments Details Value References See Also Examples

Description

Interpolate a monotone function from a two-column table

Usage

1
2
pcderiv(x,fn)
pcinterpolate(x,fn,deriv,xnew)

Arguments

x

vector of x values

fn

function values corresponding to each value in x

deriv

vector of (estimated) derivative values assuming monotonicity, output of pcderiv and input to pcinterpolate

xnew

vector of new x values to interpolate values of the function.

Details

The monotone piecewise cubic interpolation algorithm is from the references given below.

Value

deriv

for pcderiv, estimated derivatives at x values

y

for pcinterpolate, length(xnew) x 2 matrix of interpolated fn values and derivatives

References

Fritsch FN and Carlson RE (1980), Monotone piecewise cubic interpolation. Siam J Numerical Analysis, 17, 238-246.

Kahaner D, Moler CB and Nash S (1989). Numerical Methods and Software Prentice Hall.

See Also

makedeptable

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
n=21
x=seq(0,pi/2,length=n)
fn=sin(x)
der=pcderiv(x,fn)
print(cbind(der,cos(x)))
xnew=seq(.05,1.,.05)
out=pcinterpolate(x,fn,der,xnew)
fval=sin(xnew)
print(cbind(out[,1],fval,abs(out[,1]-fval)))
cat("max err in deriv : ", max(abs(der-cos(x))), "\n")
cat("max err in interp : ", max(abs(out[,1]-fval)), "\n")

YafeiXu/CopulaModel documentation built on May 9, 2019, 11:07 p.m.