Jump to content

Looking for Cubic Spline Interpolation Code


ExpertAlmost

Recommended Posts

Good morning!

 

I have a set of discrete data points from which I need to interpolate new values. My (neophyte) mathematical research suggests that cubic spline interpolation gives the best result with the least amount of calculation overhead.

 

I expected to find any number of functions in PHP (input two x,y points, and a point to interpolate: output the interpolated point) but cannot find any. I find C/C++ code, Matlab, even VBA. I could probably port some of that code over, but can anyone point me to so tested-ready-to-run code?

 

Thanks!

 

 

Link to comment
Share on other sites

Cubic spline looks like some fairly hardcore maths to code up.  Whats the background to the interpolation required?  Is is in 1D, or 2D?

 

As an aside, for anything other than basic linear interpolation, you would need to input more two input points.  Anything more complicated meeds to know a larger area which it can use to interpolate.

Link to comment
Share on other sites

"Hardcore" is a great word for it  8)

 

Actually, I have a set of 50 data points, with some of the points clustered. This is not for a graphics application, but for a statistical one.

 

What I eventually need to do is find the points that approximate 5%, 80% and 95% areas under the curve described by those points. Rarely (eg. randomly) will my actual data points hit those values. Similar to an approximation done under a bell curve but I do not have the luxury of that simplicity. Once I figure out how to do the cubic spline interpolation, I was going to use a simple trapazoidal method. Another piece of PHP code I hope to find 

 

Of course if I found a piece of code that gave me the solutions for 5%, 80% and 95% areas under a curve given a set of data points.....well....I could....take a nap 

 

Any ideas? (for the math or code --- naps I can manage)

 

Thanks

Link to comment
Share on other sites

It is financial data...so the arguments abound about various curves fitting and various fixes to various curves making things fit, etc.

 

Cubic spline interpertation is certainly close enough. Rather than spend 20 hours coding and testing php splines code, I would go to linear if I had to. I was just hoping for some luck. Cubic splines is not a new process nor is approximating areas under curves using trapezoids (Riemann sums). I am actually a bit suprised these are not in the PHP library! What happened? hahahaha

 

Hoping for the best  :D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.