1

I have some data that looks like this

Data

What is the typical way to do a polynomial map of z based on x and y? I have used numpy.polyfit in the past to do similar things in 2 dimensions, so I suppose I could just iterate through all the points and then fit those answers with another 1d polyfit. However, it seems there should be a more straight forward way.

By the way the picture shows 2 different sets of data that would be fit with different equations.

Matt
  • 954
  • 2
  • 9
  • 21
  • Possibly related: http://stackoverflow.com/questions/7997152/python-3d-polynomial-surface-fit-order-dependent – aganders3 Dec 11 '13 at 20:25
  • I saw this, but it seems a very custom solution. I am looking into it now but haven't gotten it to work out yet. – Matt Dec 11 '13 at 20:41

1 Answers1

3

It seems to me that what you really want is to fit a surface (linear or spline) in terms of z(x,y), but you have only one single line of data. This is like solving for two unknowns with only one equation - the problem is, basically, how could you decide if the difference in your red line from A to B was caused by the change in PSI, or the change in V?
My suggestions:

  • fit a surface to your existing dataset. You will get something.
  • try to get more data that you can fit a more accurate surface on
  • do what you first wanted - fit a function separately in each dimensions, combine them and use the best of the three functions (the one fitted for PSI, the one fitted for V and the one combined).
  • try to combine your PSI and V factors with some fancy physics-based trick into one significant factor that contains both of them
Community
  • 1
  • 1
leeladam
  • 1,748
  • 10
  • 15
  • 1
    I think you are right that I want to fit a surface. I have some more data at different pressures and the same voltages. Let me toy around with it some so I can be sure this is the correct answer. – Matt Dec 11 '13 at 20:49
  • While you were right that I wanted to fit a surface, I believe what I was looking for was linear regression instead of a spline. The spline will fit it, but is a bit more complicated to implement on low level hardware as a linearization. Linear regression could also be used to fit the original curve that I asked to fit, so I think that would have been the most correct answer – Matt Dec 12 '13 at 16:25