Interpolation algorithms

Hi,

I want to implement interpolation algorithms..I can only find papers or description about it...Is there any site or anything that gives info on how to implement it ..
For example, meshgrid, linspace ...something to get someone started ...
zizi21Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HooKooDooKuCommented:
Interpolation is simple mathematics.  The basic premise is you know the value of point A and you know the value of point C and you want to know the value of point B that you know is 30% of the way between A and C.  So you take the value of A and and 30% of the difference between A and C (linear interpolation).

So if A = 100 and C = 200, then B located 30% of the way to C from A is 130.

What more do you need... what exactly are you trying to interpolate?
0
evilrixSenior Software Engineer (Avast)Commented:
The GNU Science Library supports a range of interpolation methods.
http://www.gnu.org/software/gsl/

If you don't need to reinvent the wheel and you can use this library that would be my recommendations.
0
zizi21Author Commented:
I am looking for Inverse_distance_weighting
0
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

TommySzalapskiCommented:
Inverse distance weighting is very simple. You just take each point and multiply it by some function. The simplest function is 1/d (where d is the distance to the point). Some people use 1/d^2 or some other function.

So you would take all the points, calculate their distance from the target point, and compute the weighted average.
Example in untested C++ code
struct Point
{
   double x;
   double y;
   double value;
}

double InverseDistanceWeight(Point &target, Point allPoints[], int count)
{
   double total = 0;
   double sum = 0;
   double distance, weight, value;
   for (int i = 0; i < count; ++i)
   {
      // Euclidean distance
      distance = sqrt(pow(target.x - allPoints[i].x, 2) + pow(target.y - allPoints[i].y, 2));
      weight = 1/distance; // the weighting function
      value = weight * allPoints[i].value; // the adjusted value
      total += value; // sum it all up
      sum += weight;
   }

   // get the weighted average
   target.value = total/sum;
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zizi21Author Commented:
Thanks a lot...I am studying it now...
0
zizi21Author Commented:
I am confussed. Say, I have this data set. These points are allPoints[]

x=10, y=10, value=1,
x=20, y=25, value=2,
x=40, y=40, value=3

Am i correct in understanding that i would need to do a linspace on my own..
for example,
x=15, y = 15, value=?
x=25, y=35, value=?

These above points are called target? Is that right ?
0
TommySzalapskiCommented:
Yes. If you did a linspace to add points, then ran each of those new points through the InverseDistanceWeight function (using only the original points in the array), you would get the result I think you want.
0
zizi21Author Commented:
Apologies for the late reply as i lost internet connection for the day.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.