views:

1871

answers:

2

I am trying to write C++ function perform curve fitting implementation using least square method. Input parameters of this function are x and y 1D array and n. And this function finds the coefficients of a polynomial p(x) of degree n that fits the data, p(x(i)) to y(i), in a least squares sense. Therefore, function will return coefficient 1D array.

Could you help me please?

+3  A: 

Here's the basic method via MathWorld (a wonderful resource). For a C++ code, hie thyself to the local library and look it up in Numerical Recipes.

Charlie Martin
A: 

boost::ublas should have what you need for the algebra. Past that, you'll need to determine your chi-square function and minimize it.

For more specific answers, you'll likely need to update your post with more specific questions.

Ryan