Linear Regression to quadratic function

727 Views Asked by At

What is the optimal linear regression (w and w/o y-intercept) for a quadratic curve w.r.t. mean square error.

Mathematically speaking:

Given,

$$y = x^2$$

for

$$x = [-a,a]$$.

What is the best approximation for straight line equations of the form.

$$y = \alpha x$$

and

$$y = \alpha x + \beta$$.

cftool in MATLAB can solve it numerically, but I had rather have a closed form analytical solution if it exists.

2

There are 2 best solutions below

2
On BEST ANSWER

How do you measure error? Do you want to do a least squares fit? Then you have to minimize

$$\int_{-a}^a(x^2-(\alpha x+\beta))^2dx$$

which can easily be done by solving the below system for $\alpha$ and $\beta$

$$\frac{\partial}{\partial \alpha}\int_{-a}^a(x^2-(\alpha x+\beta))^2dx=0$$ $$\frac{\partial}{\partial \beta}\int_{-a}^a(x^2-(\alpha x+\beta))^2dx=0.$$

0
On

It would be the line $y=\alpha x$ such that $$\int_{-a}^a\big|x^2-\alpha x\big|dx$$ is minimum