The best fit for variables in a number of equations?

735 Views Asked by At

Let's say I have 2 variables $x$ and $y$ and 4 equations. The parameters in capital are known parameters.

$$I_1=xA_1+yB_1$$ $$I_2=xA_2+yB_2$$ $$I_3=xA_3+yB_3$$ $$I_4=xA_4+yB_4$$

What's the strategy to find the best fitting values for $x$ and $y$? What's the name of this topic so I can google it?

2

There are 2 best solutions below

3
On

You are looking for a technique called "Least-squares regression". This method allows for overdetermined systems (more equations than variables) to be fit to the polynomial that minimizes the sum of the distances (actually the sum of the squared distances) from each point to that polynomial. You specifically want the matrix version that looks like this $$A^TA\vec{x}=A^T\vec{b}$$

3
On

Let us suppose that you have $n$ data points $(A_i,B_i,I_i)$ ($i=1,\cdots,n)$ and you want to find the "best" $x$ and $y$ for matching the model $$I=x A+y B$$ the genral method, as already answered by G-Cam, is ordinary least square which consist in the minimization of $$F=\sum_{i=1}^n \big(x A_i+y B_i-I_i\big)^2$$ Computing the derivatives and setting them equal to $0$ since we look for the minimum, we get $$F'_x=2\sum_{i=1}^n \big (x A_i+y B_i-I_i\big)A_i=0$$ $$F'_y=2\sum_{i=1}^n \big (x A_i+y B_i-I_i\big)B_i=0$$ Expanding the above equations, we then have $$x \sum_{i=1}^n A_i^2+y\sum_{i=1}^n A_iB_i=\sum_{i=1}^n A_iI_i$$ $$x \sum_{i=1}^n A_iB_i+y\sum_{i=1}^n B_i^2=\sum_{i=1}^n B_iI_i$$ So, two linear equations in $(x,y)$ easy to solve.

For sure, as G-Cam mentionned, you could prefer the matrix formulation.