# Is there a method to find (fit) a function with four (4) independent variables?

I have a system with 4 sensors (say $s_1..s_4$) which I want to combine into a single signal.

I have logged the 4 outputs as well as a "control" sensor ($s_c$) which has the desired ouput signal. Since $s_1..s_4$ should contain enough information to recreate the control-signal, I now try to find a (non-linear) function to describe their relationship:$f(s_1,s_2,s_3,s_4)= s_c$ (4 independent variables, 1 dependent).

I know that there are tools available for $f(x)=y$ (2D) and $f(x,y)=z$ (3D) like curve- and surface-fitting of Matlab. Downside of those is that you already need a general idea of the function to fit to, but using (high order) fourier series often give good representations.

I thought regression analysis (least-squares) might be helpful, but then a column of additional data is required for every possible term in the function. This leads to a vast amount of data, a fourier series (sin and cos for each variable) effectively would mean $2^8$ possible combinations (terms) for just the 1st order.

Long story short: I can't seem to find a tool nor a mathematical method for "5D" fitting. Is there a way to achieve this?

Any help pointing me in the right direction is very much appreciated.

• I had once the software "graphpad prism" for experiments with curve fitting. I found it very good for extremely explorative situations - it also tests parameter combinations of different types of functions out of a pool of functions which you can define. When I had it (~2 years ago), one could test the software for 30 days - that fitted well for the problem which I then have had. – Gottfried Helms Feb 17 '12 at 13:36

Let's say you have $N$ sample points $s^j = (s_1,s_2,s_3,s_4)$, and at each one you know from your measurements that $f(s^j) = s_c^j$.
Assume $$f(s) = \sum_{j=1}^N c_j \phi(|s-s^j|)$$ where $\phi$ is a radial basis function.
Then you can find the coefficients $c_j$ by solving the matrix system $Ac = s_c$ where $A_{ij} = \phi(|s^i - s^j|)$, that is, you enforce that the approximation goes through all the sample points.
There are many choices for the RBF but standard ones are the Gaussian $\phi(r) = e^{(-\epsilon r)^2}$ or the multiquadric $\phi(r) = \sqrt{1 + (\epsilon r)^2}$, where $\epsilon$ is a parameter you get to choose based (roughly) on how closely your points are spaced.