Graduate Choosing the Right Interpolation Method for Your Data for Engineers

  • Thread starter Thread starter confused_engineer
  • Start date Start date
  • Tags Tags
    Interpolation
Click For Summary
The discussion revolves around selecting an appropriate interpolation method for a dataset consisting of X position, Y position, and recorded data. The original poster struggles with achieving a satisfactory R-squared value using NonlinearModelFit in Mathematica and finds that using InterpolatingPolynomial crashes their computer due to the high order of the polynomial. Participants suggest that interpolation may not be suitable unless the data is noise-free and recommend considering a linear model instead, especially in the absence of a theoretical model. The poster later mentions using Shannon sampling in two dimensions as a potential solution, although they encounter new issues. Ultimately, the conversation highlights the importance of understanding the nature of the data when choosing fitting methods.
confused_engineer
Messages
34
Reaction score
1
TL;DR
I have a matrix of data and X, Y position where it was recorded. I want to find out a suitable interpolation polinomial but I don't know how to obtain one of reasonable order.
Hello everyone.

I have a vector of size 300321*3; the columns are X position, Y position and recorded data; I need to find the interpolation polynomial. I have acess to mathematica, MATLAB and python.

I have attempted to use a NonlinearModelFit in mathematica, but I cannot achieve a Rsquared superior to 0.6 by constructing models by hand, that is why I want to use the interpolation polynomial instead. However, if I use the InterpolatingPolynomial function, my computer crashes and even if it didn't, the result would be useless since a polinomial of order 300321 would make no sense.

In Matlab, I have tested the function griddedinterpolant, which produces good results, however, the function does not return a polynomial, but only a grid with more points instead, these aditional ones calculated using the interpolation and located between the originaly provided.

Can someone please advice me on how to proceed?

Regards.
Confused engineer
 
Physics news on Phys.org
Do you have some theoretical relationship between x, y, and z? If not then why do you expect an R^2 greater than 0.6?

Also, why are you doing a nonlinear fit in the first place? Usually you only do nonlinear fits if you have a nonlinear model in mind for theoretical reasons.

An interpolation seems like a bad idea. Interpolation almost never makes sense unless your data is noise-free. With your R^2 value that seems unlikely. You should be looking at fitting the data to a model:

Do you have a theoretically motivated model? If not then a simple linear model is probably best.
 
Last edited:
  • Like
Likes confused_engineer
Dale said:
Do you have some theoretical relationship between x, y, and z? If not then why do you expect an R^2 greater than 0.6?

Also, why are you doing a nonlinear fit in the first place? Usually you only do nonlinear fits if you have a nonlinear model in mind for theoretical reasons.

An interpolation seems like a bad idea. Interpolation almost never makes sense unless your data is noise-free. With your R^2 value that seems unlikely. You should be looking at fitting the data to a model:

Do you have a theoretically motivated model? If not then a simple linear model is probably best.
First of all, thanks for the answer.

Second, my data doesn't have noise, since the data is the output of a prediction model (I don't know anything about it's internal working, only the output file), so I will try the lineal way instead.

About the use of interpolation instead of the fit, I do it because my professor insisted on using it instead of fitting the data.

And about the theoretical model, no I don't have one. I just attempted to use higher order terms to have a better fit.
 
confused_engineer said:
Second, my data doesn't have noise, since the data is the output of a prediction model (I don't know anything about it's internal working, only the output file),
Oh, that is different. Then interpolation does make sense. You might try something like a cubic spline interpolation. In Mathematica you can just use the Interpolation function.
 
The thing is that I cannot use piecewise interpolation, the result goes then into ampl, an optimization software (in which I am calculating the fastest route) which needs to know the value of the windspeed at all points. I need an algebraic expression of the windspeed, in this case, my f(x,y).

In the attached file you can find my model so far.
pforum.png
 
confused_engineer said:
which needs to know the value of the windspeed at all points.
Do you have a link to documentation that says the subprogram you are using requires windspeed as an algebraic expression?

The usual case in computer software would be that an optimization needs functions in the computer language sense of the word "function". Such a function can be created by writing a routine using any type of algorithm. It need not employ an algebraic expression.
 
Stephen Tashi said:
Do you have a link to documentation that says the subprogram you are using requires windspeed as an algebraic expression?

The usual case in computer software would be that an optimization needs functions in the computer language sense of the word "function". Such a function can be created by writing a routine using any type of algorithm. It need not employ an algebraic expression.
Don't worry. In the end, I found out a way to do it using Shannon sampling in two dimensions. However, I am running in some issues, but I think they deserve their own thread
 
Nomenclature: An interpolation necessarily passes exactly through each data point.
I believe that is not what you want. Instead you are looking to fit the data to a function with presumably some measure of fit quality maximized. In the age of Google semantic precision is important.
Have you looked at the data?? Is it bumpy or smooth? (does ii have lots of local maxima or not? ) That will indicate the order of a polynomial fit needed.
Shannon Sampling is essentially doing a finite Fourier series fit. It may or may not be an effective method. There is no "right " answer here .
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 5 ·
Replies
5
Views
1K
Replies
8
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
Replies
1
Views
2K
Replies
1
Views
3K