The stochastic equation for (xi, yi) becomes:
1 2 3
|
yi = - a * xi – b * xi^2 + ei;
//OR
ei = yi + a * xi + b * xi^2;
| |
where ei is the residual. Now:
(a) sum the squared residual over all (xi, yi)
(b) take the partial differentiations of this sum w.r.t a and b, which should be = 0 as per first-order conditions
(c) some assumptions about the distribution of the error (e.g. expectation 0 and orthogonal to x, y etc) will simplify the above equations further yielding the 'normal equations' which you can now solve for a^ and b^ which are estimates of a and b in the population
though your equation is not the classical OLS of econometrics any half-decent text-book on the subject (try the one by W H Greene if you will) should get you going
finally where C++ can come in handy is to arrange the X, Y data into containers like std::vector and then manipulating these vectors in solving the normal equations
you could also try Maximum Likelihood estimation using the <random> library if you wish to consider an alternative approach