Description Usage Arguments Details Value Author(s) References See Also Examples

Both functions recognize whether uni-variate or bi-variate interpolation is requested

`sps_fun`

calls `sps_prep`

to prepare spline object and according to data
provided creates uni-variate or bi-variate executable function. Parameters can be set
by specifying them as arguments

`sps_interpolate`

prepares spline and returns its values on given set of tabulation points

1 2 3 |

`x` |
Vector of x-coordinates of data. |

`y` |
Vector of y-coordinates of data. For uni-variate case length should be equal to length of |

`z` |
Bi-variate case only. Matrix of values of function on grid spanned by x and y; |

`xt, yt` |
Vectors OR Matrices containing coordinates of the tabulation point; yt for bi-variate case only |

`der, der.x, der.y` |
Indicate which derivative should be returned; der.y used in bi-variate case only. If length of vector is greater than 1 function will return list of values. For bi-variate case vectors should have equal length. At the moment only 1 and 0 are supported. See examples. |

`grid` |
For bi-variate interpolation only. If |

`...` |
arguments in |

Following parameters can be specified:

- fx, fy, fxy
Matrices with values of the derivatives: see

`sps_prep`

- maxdeg
Maximum degree of polynomial allowed: see

`sps_prep`

- smoothness
Smoothness required: see

`sps_prep`

- tol
Relative tolerance used by program

- shape
Vector of shape attributes that must be preserved. Must contain only 'monotonicity' and/or 'curvature'

`sps_fun`

Function of 1 or 2 variables depending on data provided. Function will accept vector(s) or matrix(es) of tabulation point and return object of the same class. If while calling

`sps_fun`

length der.x (and possibly der.y) was bigger than 1. Resulting function will be returning list of values of respective derivatives at given tabulation points.`sps_interpolate`

Vector, matrix or list of vectors/matrices of value of function and/or derivatives on given set of tabulation points

Szymon Sacher <[email protected]> & Andrew Clausen <[email protected]>

Excerpts adapted from Fortran code Copyright (C) Paolo Costantini

Costantini, P; Fontanella, F; 'Shape Preserving Bi-variate Interpolation' SIAM J NUMER. ANAL. Vol. 27, No.2, pp. 488-506, April 1990

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | ```
## Example 1
# Following example shows usage of sps_fun along with the parameter 'smoothness'.
# As you will see if smoothness = 2 then first derivative of function is differentiable
# everywhere.
x <- c( 1, 2, 3, 4, 5, 6)
y <- c(16 ,18, 21, 17, 15, 12)
evalK1 <- sps_fun(x, y)
derK1 <- sps_fun(x, y, der.x=1)
evalK2 <- sps_fun(x, y, smoothness = 2)
derK2 <- sps_fun(x, y, smoothness = 2, der.x = 1)
xs <- seq(1, 6, 0.01)
par(mfrow = c(2, 2))
plot(x, y, col = "red", xlim = c(0, 7), ylim = c(10, 22),
main = "Spline, smoothness = 1")
grid()
lines(xs,evalK1(xs), col="cyan")
par(new = TRUE)
plot(derK1, from = 1,to = 6, col = "magenta", xlim = c(0,7), ylim = c(-6,5),
xaxt = 'n',yaxt='n',ann = FALSE)
axis(4, -6:5)
plot(x, y, col="red", xlim=c(0,7), ylim=c(10,22),
main = "Spline, smoothness = 2")
grid()
lines(xs,evalK2(xs), col="cyan")
par(new = TRUE)
plot(derK2, from = 1, to = 6, col = "magenta", xlim = c(0,7), ylim = c(-6,5),
xaxt = 'n',yaxt = 'n', ann = FALSE)
axis(4, -6:5)
plot(derK1, from = 1.5, to = 2.5)
plot(derK2, from = 1.5, to = 2.5)
## EXAMPLE 2
par(mfrow = c(1,1))
X <- seq(0, 50, 5)
Y <- seq(0, 40, 5)
X_ <- seq(0, 50, 0.5)
Y_ <- seq(0, 40, 0.5)
persp3D(X_, Y_, sps_interpolate(X, Y, akima, X_, Y_,
grid = TRUE, shape = 'monotonicity'))
``` |

spsi documentation built on May 30, 2017, 5:46 a.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.