Really? I think I must be missing something. When I plot them in excel
I get the attached results...


On 8 August 2012 13:23, Gilles Sadowski <[email protected]> wrote:
> On Tue, Aug 07, 2012 at 11:59:09PM +0100, Mat Jaggard wrote:
>> I have tried to create a polynomial that fits some data using the
>> following code:
>>
>>                 PolynomialFitter fitter = new PolynomialFitter(14, new
>> GaussNewtonOptimizer());
>>                 for (int i = 0; i < numValues; i++)
>>                 {
>>                         fitter.addObservedPoint(xValues[i], yValues[i]);
>>                 }
>>                 return new PolynomialFunction(fitter.fit());
>>
>> I've also tried using a degree of 4. In both cases and using both a
>> GaussNewtonOptimizer and a LevenbergMarquardtOptimizer, I'm able to
>> get a straight line to be fitted correctly, but the following data
>> results with a constant value but very small multipliers for x, and
>> higher orders.
>>
>> Is anyone able to let me know why this is happening and what I can do about
>> it?
>>
>> Many thanks,
>> Mat.
>>
>> The result I get is...
>> y = 110.281064 + 0.002316943x - 3.86E-09x^2 + 4.01E-15x^3 - 1.58E-21x^4
>>
>> From this data:
>>
>> [...]
>
> Plotting those data, and the above polynomial shows that Commons Math did a
> decent job. What led you to think that the fit is not correct?
> [Maybe the data could be better fitted with another function...]
>
>
> Regards,
> Gilles
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to