3

Hi I have a cloud of XYZ data points. I want to estimate a surface which best fits these points, so that later on I can input an XY pair and get back the Z value where this XY pair lies on the surface.

Is there an existing Java library that will estimate a surface for me?

If not, can anyone recommend me stuff to read which will describe the methods for calculating this?

If possible, I want to be able to weight the points (Some points are less reliable and so should have less effect on the finished surface).

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
ed Bevan
  • 73
  • 7
  • http://en.wikipedia.org/wiki/Regression_analysis – Oliver Charlesworth Mar 03 '13 at 20:47
  • Unless I'm mistaken, this seems to only talk about 2D regression. "Regression models involve the following variables: The unknown parameters, denoted as β, which may represent a scalar or a vector. The independent variables, X. The dependent variable, Y." – ed Bevan Mar 03 '13 at 21:01
  • Yep, that's the basic case. It then extends to multivariate regression. It's not really my area, though, so I can't provide any specific advice! (However, you may find better help at http://stats.stackexchange.com). – Oliver Charlesworth Mar 03 '13 at 21:04
  • 1
    Ahaaaa, i was getting thrown off by the x independents and y dependents, thinking those could only refer to x and y values. If I've got this right, I think i can chuck the Z values in the y dependents and the x independents are a series of {1, x, y, xy, xx, yy} for quadratic or {1, x, y, xx, yy, xy, xxx, yyy, xxy, yyx} for cubic etc? – ed Bevan Mar 03 '13 at 21:23

1 Answers1

2

This kind of problem is best solved with linear least squares. However I wouldn't try reading the wikipedia article, it seems to be written for mathematicians.

The idea is to change the problem into a linear optimization one. In your case i'd try to fit a 2D polynomial. This is an equation in the form:

z(x, y) = A + Bx + Cy + Dx^2 + Exy + Ey^2 + Fx^3 + Gx^2y + Hxy^2 + Iy^3 + ...

You get the idea. For a given dataset, the task is reduced to finding the parameters A through I that best fit the data points. This kind of problem is easily solved by linear least squares.

Have a look at this code for fitting ellipses to 3D data points. With some effort you can adapt that to fit polynomials in the form I described above.

Good luck!

Hannesh
  • 7,256
  • 7
  • 46
  • 80
  • 1
    Indeed, the Wikipedia article is not the best introduction to the topic. But acquiring some basic background in the subject is probably advisable, before simply applying "arbitrary" techniques ;) – Oliver Charlesworth Mar 03 '13 at 21:25