Re: Interpolation
- From: spellucci@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (Peter Spellucci)
- Date: 19 Jan 2006 07:45:01 -0500
In article <dqmufd$fru$1@xxxxxxxxxxxxxxxxxxxxxxxxx>,
"Rose" <rosy27@xxxxxxxxx> writes:
>
>Hi
>
>Is there any kind of interpolation like spline, nearest
>neighbor(weighted) that can be used for interpolating a nonuniform data
>?
>
>Suppose x = [1 2 4 5 6 8 9 10 12....]
>and y=f(x) = [0 -2 4 -3 5 -6....]
>and i want to find yy corresponding to xx = [1.8 5.8 9.8..]
>
>How should I proceed? And can somebody please tell me equations used in
>spline as applied to this example!!
>
>Thanks
>Rose
>
any interpolation method I know of can be applied in the nonequidistant case,
the question is the numerical effort for performing this and the form
of the error bounds. for a cubic spline it is very easy, the formulae
are in any numerical analysis text and code is in
http://www/netlib.org/dierckx.
here teh equations for the "natural" cubic soline (the spline with
second derivative at the ends equal to zero:
data (x(i),y(i)) i=0,...,n+1
set
h(i)=x(i)-x(i-1), i=1,...,n+1
set Matrix
A= [ 2(h(1)+h(2)), h(2), 0 , .... , 0 ] (first row)
[ 0...0 , h(i), 2(h(i)+h(i+1)), h(i+1), 0 ... 0] row i=2,...,n-1
[ 0,....,0 h(n), 2(h(n)+h(n+1)) ] row n
(A is tridiagoanl, so there are i-2 zeroes on the left and n-i-1 zeroes
on the right)
set the right hand side
b(i)=(y(i+1)-y(i))/h(i+1)-(y(i)-y(i-1))/h(i) ; i=1,..,n
solve the linear system
A*M=b
the M(i) have the meaning
M(i) = s''(x(i))/6.
then set
d(i)=y(i)-M(i)*h(i+1)^2 i=0,..,n
c(i)=(y(i+1)-y(i))/h(i+1)-(M(i+1)-M(i))*h(i+1) , i=0,...,n
with
M(0)=M(n+1)=0
then
s(x)= (M(i+1)*(x-x(i))^3+M(i)*(x(i+1)-x)^3)/h(i+1)+c(i)*(x-x(i))+d(i)
for x(i)<=x<=x(i+1) i=0,..,n
is the equation for the spline
hth
peter
.
- References:
- Interpolation
- From: Rose
- Interpolation
- Prev by Date: Re: Interpolation
- Next by Date: categories and trees
- Previous by thread: Re: Interpolation
- Next by thread: Winter Pacific NW Geometry Seminar at Stanford
- Index(es):
Relevant Pages
|