Current location - Training Enrollment Network - Mathematics courses - How does MATLAB predict the numerical change after this dependent variable in the case of three independent variables 1 dependent variable? These three independent variables predict the future figures
How does MATLAB predict the numerical change after this dependent variable in the case of three independent variables 1 dependent variable? These three independent variables predict the future figures
How does MATLAB predict the numerical change after this dependent variable in the case of three independent variables 1 dependent variable? These three independent variables predict the future figures. If you know that X 123 can find Y, you can use your formula directly.

Code:

x 1 =[x 1 1 x 12...x 1n]; The% line vector has n numbers, the same below.

X2=[x2 1 x22...x2n];

X3=[x3 1 x32...x3n];

y = A0+a 1 * x 1+A2 * X2+A3 * X3; %A0 123 are four known numbers.

In this way, the row vector y of 1 row and n columns is obtained.

As for your "prediction", I guess A0 123 is the undetermined coefficient.

That is to say, the n components of X 123 and y are known, so we hope to fit them with ternary linear functions.

In this case, if the least square method is used, the idea is:

{Below I use sum(f(i), 1, 10) to represent the value of f(i) expression from 1 to 10. }

Let A0 123 be the undetermined coefficient, and calculate the estimated value YY of Y with X 123.

YY = sum(A0+a 1 * x 1i+A2 * X2i+A3 * X3i, 1,n)

Second, calculate the square of the difference between true y and estimated YY, and then sum S.

s=sum((a0+a 1*x 1i+a2*x2i+a3*x3i-yi)^2, 1,n)

Thirdly, the aim is to find A0 123 which minimizes S, that is, the least square solution.

This is actually a problem of finding the extreme value of differentiable multidimensional functions, which can be solved by finding the partial derivatives of their respective variables and taking zero at the same time.

At this time, the partial derivatives of A0 123 are obtained for the above S equations.

dS/dA0 = sum(2 *(A0+a 1 * x 1i+A2 * X2i+A3 * X3i-Yi), 1,n)

dS/da 1 = sum(2 *(A0+a 1 * x 1i+A2 * X2i+A3 * X3i-Yi)* x 1i, 1,n)

dS/dA2 = sum(2 *(A0+a 1 * x 1i+A2 * X2i+A3 * X3i-Yi)* X2i, 1,n)

dS/dA3 = sum(2 *(A0+a 1 * x 1i+A2 * X2i+A3 * X3i-Yi)* X3i, 1,n)

A0 123 is extracted from the right side of Equation 4 above, and then both sides are divided by 2.

(dS/dA0)/2 = A0 * n+a 1 * sum(x 1,n)+A2*sum(X2i, 1,n)+A3*sum(X3i, 1,n)-sum(Y, 1,n)

(dS/da 1)/2 = A0 * sum(x 1i, 1,n)+A 1*sum(X 1i, 1,n)+A2*sum(X2i*X 1i, 1,n)+A3*sum(X3i*X 1i,65438

(dS/dA2)/2=A0*sum(X2i, 1,n)+A 1*sum(X 1i*X2i, 1,n)+A2*sum(X2i*X2i, 1,n)+A3*sum(X3i*X2i, 1,n)-sum(Y*X2i, 1,n)

(dS/dA3)/2=A0*sum(X3i, 1,n)+A 1*sum(X 1i*X3i, 1,n)+A2*sum(X2i*X3i, 1,n)+A3*sum(X3i*X3i, 1,n)-sum(Y*X3i, 1,n)

Let the left side of Equation 4 above be 0, and notice that the right side is in the form of "A0* known constant +A 1* known constant +A2* known constant +A3* known constant-known constant".

In this way, we can get a quartic linear nonhomogeneous equation set, which can be solved by the method of solving linear equations in higher mathematics (even method of substitution in junior high school).

In this way, the best four numbers A0 123 are obtained. These four parameters make the fitting function y = A0+a1* x1+a2 * x2+a3 * x3 have the smallest difference with the given data X 123 and y, that is, the best fitting.