[SciPy-user] Optimization Working only with a Specific Expression of the input Parameters
Fri Mar 2 07:50:53 CST 2007
I'm just an amateur, but it seems to me like the array data in myvar1 are
likely integers. When you raise the data to a power of type float (i.e.
2.0) all the members of the array are automatically converted to real
(float) types. Easiest and fastest thing I know to do would be:
myvar1 = myvar1*1.0
Or, and probably preferred (assuming you are using the numpy array type and
have imported it):
myvar1 = numpy.array(myvar1,dtype=float)
At 08:25 AM 3/2/2007, you wrote:
>I was trying to fit some data using the leastsq package in
>scipy.optimize. The function I would like to use to fit my data is:
> where A1, mu1 and myvar1 are fitting parameters.
>For some reason, I used to get an error message from scipy.optimize
>telling me that I was not working with an array of floats.
>I suppose that this is due to the fact that the optimizer also tries
>solving for negative values of mu1 and myvar1, for which the log
>function (x is always positive) does not exist.
>In fact, if I use the fitting function:
>Where mu1 and myvar1 appear squared, then the problem does not exist
>any longer and the results are absolutely ok.
>Can anyone enlighten me here and confirm this is what is really going on?
>SciPy-user mailing list
Brandon C. Nuttall
BNUTTALL@UKY.EDU Kentucky Geological Survey
(859) 257-5500 University of Kentucky
(859) 257-1147 (fax) 228 Mining & Mineral
http://www.uky.edu/KGS/home.htm Lexington, Kentucky 40506-0107
More information about the SciPy-user