in reply to mathsy question: finding max of curve from discrete points
Given (x1,y1), (x2,y2)...(xn, yn) are your data points, a least squares solution can be found by creating a matrix A as such:
x12 x1 1
x22 x2 1
...
xnn xn 1
and a vector b as such:
y1
y2
...
yn
We then want to solve for a vector x = (A, B, C) such that:
ATAx = ATb.
(Where AT is the matrix transpose of A). The A, B, and C that you find by solving that equation will be the coefficients in the quadratic polynomial y = Ax2 + Bx + C. If you know how to do matrix arithmetic, you should be able to swing it. I think that there are also modules on the CPAN that could help you with that.
thor
|
|---|