Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Library: xplore
See also: approx

Quantlet: linapprox
Description: interpolates linearly from given discretized one-dimensional functions on the same grid.

Usage: y = linapprox(f,x {,v})
Input:
f n x 2 matrix of x-values (first column) and function values (second to last column), sorted by the first column.
x m x 1 vector of new x-values.
v optional scalar, value to be set outside the range of f[,1]. If not given, linear extrapolation is used.
Output:
y m x (p-1), vector of new function values.

Example:
library("xplore")
z=(1:5)*2
f=z~(z^2)
randomize(117)
x=uniform(8)*10
y=linapprox(f,x)
y
library("plot")
f=setmask(f,"medium","green","fillcircle","line","green")
plot(setmask(x~y,"large","cross"),f)

Result:
A graph with the original and interpolated values is
shown.

Contents of y
[1,]  -4.9646
[2,]   37.317
[3,]    13.42
[4,]   1.7342
[5,]   66.715
[6,]   69.481
[7,]   61.838
[8,]   42.354
Example:
library("xplore")
z=(1:5)*2
f=z~(z^2)
randomize(117)
x=uniform(8)*10
y1=linapprox(f,x)
y2=linapprox(f,x,NaN)
y1~y2

Result:
Contents of _tmp
  [1,]  -4.9646     +NaN
  [2,]   37.317   37.317
  [3,]    13.42    13.42
  [4,]   1.7342     +NaN
  [5,]   66.715   66.715
  [6,]   69.481   69.481
  [7,]   61.838   61.838
  [8,]   42.354   42.354



Author: M. Mueller, 20020304
(C) MD*TECH Method and Data Technologies, 05.02.2006