How to find a function, given the parameters and return value?

386 Views Asked by At

So as one of my hobby computer science exercises, I've decided that I need a function which would accept two parameters. The function would return some value for these parameters.

I have a sample of ~20 samples of (param1, param2, output). I want to make sure that the function will always return the proper result for the parameters from the training set.

This looks a lot like a machine learning problem. However, my problem isn't really linear, so I believe I'm not looking for linear regression. I probably need some polynomial, but I do not know what polynomial do I need.

Are there some methods to find such functions? Are there any tools to help me? Is this problem solvable in general case?

1

There are 1 best solutions below

2
On BEST ANSWER

You have a set of ordered pairs (and for every $x$ value there is only one $y$ value) and you want a polynomial that goes trough every point?

Set up this table.

$\begin {matrix} x_i&y_i&F_{1,i}&F_{2,i}&F_{3,i}\\ x_3&y_3\\ x_2&y_2&\frac {y_3-y_2}{x_3-x_2}\\ x_1&y_1&\frac {y_2-y_1}{x_2-x_1}&\frac {\frac {y_3-y_2}{x_3-x_2} - \frac {y_2-y_1}{x_2-x_1}}{x_3-x_1} \\ x_0&y_0&\frac {y_1-y_0}{x_1-x_0}&\frac {\frac {y_2-y_1}{x_2-x_1} - \frac {y_1-y_0}{x_1-x_0}}{x_2-x_0}& \frac {F_{2,1}-F_{2,0}}{x_3-x_0}\end{matrix}$

Do you see the pattern to add more data if you wish?

your polynomial:

$f(x) = y_0 + F_{1,0} (x-x_0) + F_{2,0}(x-x_1)(x-x_0)+ F_{3,0}(x-x_2)(x-x_1)(x-x_0)$

This should go through your full data set.