[SciPy-user] Optimization Working only with a Specific Expression of the input Parameters
Brandon Nuttall
bnuttall@uky....
Fri Mar 2 07:50:53 CST 2007
Hello,
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)
Brandon
At 08:25 AM 3/2/2007, you wrote:
>Dear All,
>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:
>
>log(10.0)*A1/sqrt(2.0*pi)/log(myvar1)*exp(-((log(x/mu1))**2.0)/2.0/log(myvar1)/log(myvar1)))
>
> 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:
>
>log(10.0)*A1/sqrt(2.0*pi)/log(myvar1**2.0)*exp(-((log(x/mu1**2.0))**2.0)/2.0/log(myvar1**2.0)/log(myvar1**2.0)))
>
>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?
>Kind Regards
>
>Lorenzo
>_______________________________________________
>SciPy-user mailing list
>SciPy-user@scipy.org
>http://projects.scipy.org/mailman/listinfo/scipy-user
Brandon C. Nuttall
BNUTTALL@UKY.EDU Kentucky Geological Survey
(859) 257-5500 University of Kentucky
(859) 257-1147 (fax) 228 Mining & Mineral
Resources Bldg
http://www.uky.edu/KGS/home.htm Lexington, Kentucky 40506-0107
More information about the SciPy-user
mailing list