Building on what @eigenchris said, simply take the natural logarithm (log
in MATLAB) of both sides of the equation. If we do this, we would in fact be linearizing the equation in log
space. In other words, given your original equation:
We get:
However, this isn't exactly polynomial regression. This is more of a least squares fitting of your points. Specifically, what you would do is given a set of y
and set pair of (u,a)
points, you would build a system of equations and solve for this system via least squares. In other words, given the set y = (y_0, y_1, y_2,...y_N)
, and (u,a) = ((u_0, a_0), (u_1, a_1), ..., (u_N, a_N))
, where N
is the number of points that you have, you would build your system of equations like so:
This can be written in matrix form:
To solve for A
and B
, you simply need to find the least-squares solution. You can see that it's in the form of:
Y = AX
To solve for X
, we use what is called the pseudoinverse. As such:
X = A^{*} * Y
A^{*}
is the pseudoinverse. This can eloquently be done in MATLAB using the \
or mldivide
operator. All you have to do is build a vector of y
values with the log
taken, as well as building the matrix of u
and a
values. Therefore, if your points (u,a)
are stored in U
and A
respectively, as well as the values of y
stored in Y
, you would simply do this:
x = [u.^2 a.^3] \ log(y);
x(1)
will contain the coefficient for A
, while x(2)
will contain the coefficient for B
. As A. Donda has noted in his answer (which I embarrassingly forgot about), the values of A
and B
are obtained assuming that the errors with respect to the exact curve you are trying to fit to are normally (Gaussian) distributed with a constant variance. The errors also need to be additive. If this is not the case, then your parameters achieved may not represent the best fit possible.
See this Wikipedia page for more details on what assumptions least-squares fitting takes:
http://en.wikipedia.org/wiki/Least_squares#Least_squares.2C_regression_analysis_and_statistics
log(y)
data instead of they
data. – eigenchris