# Finding a function's coefficients from inputs and target outputs

• Jan 4th 2011, 07:34 AM
ARozanski
Finding a function's coefficients from inputs and target outputs
Hi There,

I have a mathematical problem and all I require is direction as to how to go about solving it.

I have 3 variable non-linear function, \$\displaystyle x_1 x_2 x_3\$, whose values are either 0 or 1. The function f is as follows:
\$\displaystyle f(x_1,x_2,x_3) = a*x_1 + b*x_2 + c*x_3 + d*x_1x_2 + e*x_1x_3 + f*x_2x_3 + g*x_1x_2x_3\$
I have a huge sample of different values of x1 x2 x3 and a huge sample of the output (call it 'Z', whose value is also either 0 or 1) such as:

\$\displaystyle f(x_i,x_j,x_k) = Z_(ijk)\$

How would I go about calculating the values of 'a' to 'g', if I know the input and the output? I was thinking about using a neural network. Does anyone have any better ideas?

PS - excuse the long explanation.
• Jan 4th 2011, 11:52 AM
snowtea
If you can choose the input, then knowing values at (1,0,0), (0,1,0), (0,0,1), (1,1,0), (0,1,1), (1,0,1), (1,1,1) will probably be the easiest way to get all coefficients.

If you cannot choose the input. In general, for polynomials where you know the maximum degree, you can write the most general form of the polynomial. For your equation, plugging in 7 points will give 7 linear equations with 7 unknown coefficients. Assuming you picked points that give linearly independent equations, you can directly solve for the coefficients.
• Jan 5th 2011, 08:43 AM
ARozanski
Quote:

Originally Posted by snowtea
If you can choose the input, then knowing values at (1,0,0), (0,1,0), (0,0,1), (1,1,0), (0,1,1), (1,0,1), (1,1,1) will probably be the easiest way to get all coefficients.

If you cannot choose the input. In general, for polynomials where you know the maximum degree, you can write the most general form of the polynomial. For your equation, plugging in 7 points will give 7 linear equations with 7 unknown coefficients. Assuming you picked points that give linearly independent equations, you can directly solve for the coefficients.

The problem is that the function will never be exact. I have about 500 samples and the inputs need to get to as close to the target output as possible, but of course they will never be exact. This is why I was thinking of using a Neural Network. For argument's sake, my real function has 7 variables, which gives 2^7 coefficients. I apologize for not explaining properly in the first place.
• Jan 5th 2011, 08:47 AM
snowtea
So for your samples, each input produces an output with error?
If that is the case, you should use some regression technique.
• Jan 5th 2011, 10:22 AM
ARozanski
Quote:

Originally Posted by snowtea
So for your samples, each input produces an output with error?
If that is the case, you should use some regression technique.

Excuse my ignorance - I completed my degree in Applied Mathematics a very long time ago, but aren't regression or interpolation techniques when a function goes through exact points?

To go into more detail into my problem I will give an example of a similar situation. I have a sample of 500 people who have 7 characteristics. With these characteristics a bank has said either: Yes, we will give you a loan OR No, we will not give you a loan. Of course the bank has gone into more details with these 500 clients, so there could be more than two people with the same characteristics but with the same answer.

I am now needed to build a function which will take this sample of 500 people and create a function that is as close to the truth as possible so that next time said bank has another 500 people, they can estimate who will get a Yes or a No.

I am extremely sorry for the long explanation again.

If this is a type of interpolation or regression technique then if you could please name a specific technique so that I may research it and apply it. Thanks again in advance.
• Jan 5th 2011, 10:57 AM
snowtea
Ok, that makes sense. I didn't catch the part about only taking values 0 and 1.

What confuses me is that you already gave a function of form:
\$\displaystyle f(x_1,x_2,x_3) = a*x_1 + b*x_2 + c*x_3 + d*x_1x_2 + e*x_1x_3 + f*x_2x_3 + g*x_1x_2x_3\$
How did you come up with this? Does + mean the OR operator? Otherwise, it could easily be larger than 1.

Also, for a specific input, do you know the exact output (0 or 1)?
In you know the exact output, then just create a truth table.
If you do not know the exact output, then how can you write the function?
• Jan 5th 2011, 11:20 AM
ARozanski
Quote:

Originally Posted by snowtea
Ok, that makes sense. I didn't catch the part about only taking values 0 and 1.

What confuses me is that you already gave a function of form:
\$\displaystyle f(x_1,x_2,x_3) = a*x_1 + b*x_2 + c*x_3 + d*x_1x_2 + e*x_1x_3 + f*x_2x_3 + g*x_1x_2x_3\$
How did you come up with this? Does + mean the OR operator? Otherwise, it could easily be larger than 1.

Also, for a specific input, do you know the exact output (0 or 1)?
In you know the exact output, then just create a truth table.
If you do not know the exact output, then how can you write the function?

No no. It is definitely not as easy as a truth table. The + signs are not OR. The function I initially defined was just to simplify the problem by making it 3 variable and not a 7 variable non-linear function. My goal is to find the values of the coefficients of this function with the knowledge of the inputs of the 7 variables, having the values of 0 or 1 and the output also having the value of either 0 or 1. The fact that the input/output is 0 or 1 here, in my opinion, is irrelevant. I have a sample of 500 inputs and relevant outputs. I need to build a function which will, as close as possible, resemble these inputs/outputs
• Jan 5th 2011, 11:34 AM
snowtea
If you have a function mapping from an arbitrary (finite?) domain to 0 or 1, and you have no other constraints, then it is not possible to write the function. This is why model checking computer programs (that output 0 or 1) easily results in state explosion (most of the time you have to check every single possible input).

Are you trying to make guesses based on existing patterns in the data? If so, then this sounds like a data mining problem (which you could use Bayesian regression or more advanced techniques). Unfortunately, my expertise is very limited in this area.
• Jan 5th 2011, 11:37 AM
ARozanski
Quote:

Originally Posted by snowtea
If you have a function mapping from an arbitrary (finite?) domain to 0 or 1, and you have no other constraints, then it is not possible to write the function. This is why model checking computer programs (that output 0 or 1) easily results in state explosion (most of the time you have to check every single possible input).

Are you trying to make guesses based on existing patterns in the data? If so, then this sounds like a data mining problem (which you could use Bayesian regression or more advanced techniques). Unfortunately, my expertise is very limited in this area.

Yes, I am trying to make guesses based on existing patterns. I will look into Bayesian regression. Thank you for your help