1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Extrapolation for Two Dimensional Lookup Table

  1. Feb 3, 2016 #1
    Hello,

    I am writing a program for a two dimensional look up table. The idea is that the user will enter values for x and y and the program will look up the corresponding output value from the table.

    For example, consider the table shown below.
    ?temp_hash=3a97b4d1aca29d600dd623db3b9ad3a5.png

    For this table, if the user enters x = 2 and y = 1 then the program will output 6.

    If the user enters values between two entries of the table then the program will interpolate. For example, using the same table shown in the attached *.pdf, if the user enters x = 1 and y = 1.5 then the program will output 1.5.

    Furthermore, if the user enters x = 1.25 and y = 1.25 the program will use bilinear interpolation and output 2.5.

    With this I am able to handle every x and y input that is within the x and y ranges provided in the table.

    However, if the user enters input values that are outside the range of the table, how should the program determine its output?

    If we think our 2d table as a 2d mesh, where every point on the mesh corresponds to an entry in the table, then we can see that I have 9 different regions that I must deal with depending on the users input of x and y.

    ?temp_hash=3a97b4d1aca29d600dd623db3b9ad3a5.png

    In each of these regions, I must select 4 points so that I can formulate a surface, [tex]f(x,y) = a_0 + a_1 x + a_2 y + a_3 x y[/tex] and solve the for the coefficients [tex]a_0, a_1, a_2, a_3[/tex].

    Whenever the input point (x,y) is within the boundaries of the 2d mesh (i.e. marked region 9 in the *.pdf) then selecting the 4 points to use is easy, I just select the 4 surrounding points on the mesh.

    However, whenever the input point (x,y) is outside the boundaries of the mesh, I don't know how to intelligently select which 4 points to use to define my surface.

    Any ideas/comments/suggestions?
     

    Attached Files:

  2. jcsd
  3. Feb 3, 2016 #2
    Extrapolation can never be done with as much confidence as interpolation.

    If you think a linear approach is reasonable outside of the table bounds, I would fit the data to a plane f(x, y) = ax + by +c and use that plane to estimate values beyond the boundaries.
     
  4. Feb 3, 2016 #3
    Hi Dr. Courtney,

    Thanks for your reply.

    If I'm going to use a plane, then I need some mechanism to decide which three points I am going to use to define that plane. Also, for there to be a solution, the three points I select cannot lie on the same line either.

    Do you have any ideas as to how I should select which three points should be used to define my plane? I imagine this will depend on which particular region the users input lands in?

    Thanks!
     
  5. Feb 3, 2016 #4
    Do a least squares fit to all the points. It minimizes the sum of the squared errors from the points to the best fit plane.
     
  6. Feb 3, 2016 #5
    Is there a meaningful expectation about how the function behaves outside the boundaries of the table? For instance, based on the physical meaning of the data / function? If not, then the best approach may be to have your program check the user input values first, and print to output "Input values are out of bounds" or something similar. Otherwise, the user is going to get results based on Your interpretation of how the function behaves.
     
  7. Feb 3, 2016 #6

    Ordinarily, I would agree. But if you look at the table of data in this case, it is very close to a linear function:

    f(x, y) = 5(x - 1) + y

    In such cases where the agreement is so good within the range, it is unlikely that the extrapolation does not remain reasonable for at least a small amount outside the domain of the table. Therefore, I would recommend at least giving a linearly extrapolated value with a warning that it is an extrapolated value and that accuracy may degrade quickly for numbers well outside of the domain of the data on which it is based.
     
  8. Feb 3, 2016 #7
    I was under the impression that the specific table given was just an example and the OP was trying to write a generic algorithm for double interpolation. I see now that was just my assumption.
     
  9. Feb 3, 2016 #8
    You might be right. Of course, the reasonableness of extrapolation with a linear function (plane) depends on how linear the data is.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Extrapolation for Two Dimensional Lookup Table
Loading...