# 2D data fitting

I have some numbers as a function of 2 variables: $(x, y) \mapsto z$.

I would like to know which function $z=z(x,y)$ best fits my data.

Unfortunately, I don't have any hint, I mean, there's no theoretical background on these numbers. They're the result ($z$) of some FEM simulations of a system, being the simulation a parametric sweep over two parameters ($x$ and $y$) of the system.

Here's my data:

x = [1 2 4 6 8 10 13 17 21 25];
y = [0.2 0.5 1 2 4 7 10 14 18 22];
z = [1 0.6844 0.3048 0.2124 0.1689 0.1432 0.1192 0.1015 0.0908 0.0841;...
1.000 0.7096 0.3595 0.2731 0.2322 0.2081 0.1857 0.1690 0.1590 0.1529;...
1.000 0.7451 0.4362 0.3585 0.3217 0.2999 0.2797 0.2648 0.2561 0.2504;...
1.000 0.7979 0.5519 0.4877 0.4574 0.4394 0.4228 0.4107 0.4037 0.3994;...
1.000 0.8628 0.6945 0.6490 0.6271 0.6145 0.6027 0.5945 0.5896 0.5870;...
1.000 0.9131 0.8057 0.7758 0.7614 0.7531 0.7457 0.7410 0.7383 0.7368;...
1.000 0.9397 0.8647 0.8436 0.8333 0.8278 0.8228 0.8195 0.8181 0.8171;...
1.000 0.9594 0.9087 0.8942 0.8877 0.8839 0.8808 0.8791 0.8783 0.8777;...
1.000 0.9705 0.9342 0.9238 0.9190 0.9165 0.9145 0.9133 0.9131 0.9127;...
1.000 0.9776 0.9502 0.9425 0.9390 0.9372 0.9358 0.9352 0.9349 0.9348];

I tried with MATLAB with the Curve Fitting app, but I didn't succeed. The 'polynomial' fitting doesn't work well. I would like to use the 'custom equation' fitting, but I don't know what equation to start. I don't have much practice in data analysis.

• Could you make a scatter plot of your data available ? – Claude Leibovici Feb 21 '14 at 12:03
• Added in the question. – plmntt Feb 21 '14 at 13:45

Considering the shape of the $z(x,y)$ plot :

It seems better to consider $z-1$ as a function of $(x-1)$ and of $y$

A polynomial function of $(x-1)$ might be convenient. The first trial is made with a second degree polynomial.

Exponential functions of $y$ might be better than polynomial. The first trial is made with two exponentials.

The coefficients $c_1, c_2, c_3, c_4$ were adjusted by linear regression (least squares fitting) The coefficients in exponent were roughly adjusted in a first provisional approach. More accurate result would require more refined method.

The result is shown below. The standard deviation is $0.0014$

• Thank you for your answer, but there's a little mistake. In your "original data" table, you assumed that my "x data" is the first row of the "z matrix", but that's not true: my "x data" was given in the question and it's: x = [1 2 4 6 8 10 13 17 21 25]; – plmntt Feb 25 '14 at 8:29
• Sorry for the mistake. A confusion occurs in the transfer of your data to my software. Unfortunately, I didn't notice it. – JJacquelin Feb 25 '14 at 11:36
• Don't worry! If you have any other suggestion, it would be appreciated! – plmntt Feb 25 '14 at 11:57

Try Eureqa. It's awesome.

As their add says, it's a breakthrough technology that uncovers the intrinsic relationships hidden within complex data.

It works very simply: after downloading the software, you can insert your data (as vectors or as a matrix) and describe the relationship you want to find (i.e. $z = f(x,y)$). Then, after selecting which functions you want the software to use to fit, you press play and... that's all! In 10 minutes, you will get your perfect data fitting.