0

I'm currently studying numerical methods with python, and i've got a problem with the implementation of some mathematical logic. Suppose i have a table:

data:

        x = 0    x = 2    x =  4 
_______________________________
y = 0 | 100.0    90.0     80.0
y = 2 | 85.0     64.49    53.50
y = 4 | 70 48.   90       38.43

out of this data, how can i predict the value when x = 4 and y = 3.5 ?

I just need to predict the value within the range of data in the table. How can I do this? Any suggestions will be much appreciated.. thanks :)

RyeRai
  • 118
  • 1
  • 2
  • 10
  • Prediction requires a model. IE, how do your samples reflect the underlying reality. You will need to answer that question first. Then someone can help you code a way to calculate what is needed based on the model. – Stephen Rauch Mar 08 '18 at 02:49
  • not pretty sure if i understand the model, but the data in the table shows the the variation of temperature of a heated plate at various points (x,y), so i want to estimate the temperature in certain point inside the range given in table. – RyeRai Mar 08 '18 at 02:58
  • So you are assuming a linear relationship between sample points? – Stephen Rauch Mar 08 '18 at 02:59
  • https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.interpolate.html – Alexander Mar 08 '18 at 02:59
  • @StephenRauch probably , and also the temperature having inverse relationship with the x&y coordinates – RyeRai Mar 08 '18 at 03:01
  • @Alexander thanks for linking documentation, sounds interesting :) – RyeRai Mar 08 '18 at 03:03
  • Linear does not care about inverse, that is just a negative sign. If linear follow Alexander's link. If pandas is a bit much (it can be overwhelming, but it is awesome) then maybe scipy here: https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.interpolate.interp2d.html – Stephen Rauch Mar 08 '18 at 03:04
  • @StephenRauch ohhh , yeah ur right ..thank you :) i'll look into it :) – RyeRai Mar 08 '18 at 03:07

1 Answers1

0

You are trying to fit a function f(x,y) = z where z is the value in the table and (x,y) are the x and y values in your table -- a fit in 3 dimensions.

This post 3D curvefitting and this code https://gist.github.com/amroamroamro/1db8d69b4b65e8bc66a6 should provide examples of how to do this in python. The code includes implementations for a linear and quadratic fit. You'll want to choose the type of fit based on the data you are working with.

alexbhandari
  • 1,310
  • 12
  • 21