Choosing the Right Interpolation Method for Your Data for Engineers

  • Context: Graduate 
  • Thread starter Thread starter confused_engineer
  • Start date Start date
  • Tags Tags
    Interpolation
Click For Summary

Discussion Overview

The discussion revolves around selecting an appropriate interpolation method for a dataset consisting of X and Y positions along with recorded data. Participants explore various approaches using tools like Mathematica, MATLAB, and Python, while addressing the challenges of fitting a polynomial to a large dataset and the implications of noise in the data.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant expresses difficulty achieving a satisfactory R-squared value using NonlinearModelFit in Mathematica and seeks alternatives for interpolation.
  • Another participant questions the rationale behind expecting a high R-squared value without a theoretical relationship between the variables and suggests that interpolation may not be suitable due to potential noise in the data.
  • A later reply indicates that if the data is noise-free, interpolation could be appropriate, recommending cubic spline interpolation as a potential method.
  • Concerns are raised about the need for an algebraic expression of windspeed for optimization software, with a suggestion that functions do not necessarily need to be algebraic expressions.
  • One participant mentions finding a solution using Shannon sampling in two dimensions, although they encounter issues that may require further discussion.
  • Another participant clarifies that interpolation passes through all data points, which may not align with the goal of fitting the data to a function that maximizes fit quality.
  • Discussion includes considerations about the smoothness or bumpy nature of the data, which could influence the choice of polynomial fit order.

Areas of Agreement / Disagreement

Participants express differing views on the appropriateness of interpolation versus fitting a model to the data. There is no consensus on the best approach, and multiple competing views remain regarding the handling of the dataset.

Contextual Notes

Participants note the potential limitations of using interpolation with noisy data and the necessity for an algebraic expression in the context of optimization software, which remains unresolved. The discussion also highlights the importance of understanding the data's characteristics when selecting 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   Reactions: 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 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
8
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
Replies
1
Views
2K