[SciPy-User] Leastsq questions

David Baddeley david_baddeley@yahoo.com...
Mon Jun 14 15:52:07 CDT 2010


Not too sure about Excel or R squared (is R squared appropriate for nonlinear fits?), but can coment on your additional factors.  Why don't you just make them parameters? Leastsq will then do the optimisation for you. Note that the parameter argument to leastsq can be an array. For a goodness of fit it should be relatively easy to calculate Chi - squared or something similar.

Cheers,
David


----- Original Message ----
From: Timothy Kinney <timothyjkinney@gmail.com>
To: scipy-user@scipy.org
Sent: Tue, 15 June, 2010 8:28:14 AM
Subject: [SciPy-User] Leastsq questions

Scipy Community,

I am using the scipy leastsq method to fit some cooling data, such
that the temperature is defined by an exponential decay function
(Newton's Cooling Law). However, there are some other factors which
also influence the cooling rate and I am attempting to account for
them in the cooling law. I have some questions about leastsq:

1) When I fit the data in Excel I get a different fit than when I fit
the same data in Scipy. Why is this? The fits are not very different,
but they are consistently different.

2) How do I calculate the goodness of fit (R squared) for the leastsq
algorithm? I think it's just the sum of the squared errors divided by
something, but shouldn't this be easily called from the output?

I would like to iterate over a computation where I change one of the
values and see how it effects the goodness of the fit. I'm not sure
how to calculate the r-squared from the plsq that is returned from
leastsq.

My goal is to find the value of a single parameter that best optimizes
the leastsq fit. Should I be using one of the other optimizing
functions for this instead? Basically, I calculate a value from the
theory and compare it to the experimental data. I fit the theory to
the data and look at the r-squared. I want to adjust the theory to
account for some other factors by adjusting one of the terms in a way
that maximizes the goodness of fit.

Thanks for your attention.

-Tim
_______________________________________________
SciPy-User mailing list
SciPy-User@scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user



      


More information about the SciPy-User mailing list