Archived

This topic is now archived and is closed to further replies.

Obtainchi

Interpolation Understanding

Recommended Posts

Obtainchi    122
float linearInterpolate(float p1,float p2,float mu)
{
   return(p1*(1-mu) + (p2*mu));
}
 
My understanding of this would be that, p1 should be meeting p2''s value at a rate of mu, am I correct? If so, then is my method above right?

Share this post


Link to post
Share on other sites
Atheist    150
Maybe the form
p(mu) = p1 + (p2-p1)*mu
makes more sense to you. You start from p1 and go towards p2. At mu=1 (mu is the parameter ho far you went) you have reached p2. At 0
Note that p(mu) goes from p1 to p2; p1 and p2 remain static.

Share this post


Link to post
Share on other sites
grhodes_at_work    1385
p1 and p2 are the endpoints. Neither changes. The interpolated value is always somewhere between p1 and p2. When mu is 0, the interpolated value is p1. When mu is 1, the interpolated value is p2. But, the endpoints do not change.

Athiest has written the more intuitive form. Your point, your interpolated value, is p(mu), a function of the parameter mu. It then, is equal to the linear interpolation between p1 and p2.

Your function is correct, and is equivalent to Athiest''s:

p(mu) = p1*(1-mu) + (p2*mu);

is the same as:

p(mu) = p1 + (p2-p1)*mu

which you can verify by doing some simple algebra.

Graham Rhodes
Principal Scientist
Applied Research Associates, Inc.

Share this post


Link to post
Share on other sites
shadow12345    100
I asked somebody from a mathwebsite how a TI83 does square root, and one of the things mentioned was to perform quadratic interpolation between some values...what does this mean exactly? I understand what linear interpolation is, but I don''t know how you would do quadratic interpolation.

Share this post


Link to post
Share on other sites
szinkopa    198
I think for a n-order interpolation you need n+1 points given.
So for linear (n=1), you interpolate based on 2 points.
For quadratic (n=2), you should have 3 points to interpolate between them. In this case you get a point on the parabola, which these 3 points define.
For cubic ... and so on

I hope it''s clear.

Share this post


Link to post
Share on other sites
shadow12345    100
that makes sense, but I could have sworn that he said ''interpolate between two values''. I''m trying to find the email but im pretty sure i deleted it.

Share this post


Link to post
Share on other sites
szinkopa    198
What I wrote is Lagrange interpolation. This uses n-1 order polynoms for n points.
Check this out:

http://mathworld.wolfram.com/LagrangeInterpolatingPolynomial.html

Share this post


Link to post
Share on other sites
ygor_freire    122
Lagrange sux... very unstable, if your data has a minimal noise it screw up everything.
Try cubic spline: http://www.library.cornell.edu/nr/bookcpdf/c3-3.pdf

Share this post


Link to post
Share on other sites