# [SciPy-User] scipy.optimize.leastsq question

Mon Jun 28 09:52:16 CDT 2010

```
Den 28.06.10 15.44, skrev Bruce Southey:
> You probably have a scaling issue because your 'r_i' parameter is huge
> compared to your 'ppw' parameter (300 vs 0.000001). This is really
> really important if you model is nonlinear. So please try to standardize
> your values so that the parameters have similar magnitude - even just
> division/multiplication by some power of 10 can make a huge difference.
> If these parameters are so different or you need 'leastsq' then you
> probably should try either grid searching or fixing one or two
> parameters at a time. This will at least give you an idea on the
> possible values.
>
> Bruce

I have little experience with non-linear optimization so using least
squares was a first guess approach.
The model is much more sensitive to the r_i and r_s parameters than it
is to the ppw parameter. In the approach I use, all quantities are
physical units which serve as input parameters to existing routines.
They demand the given order of magnitude for r_i, r_s and ppw.
I rewrote them, so that the input variable have the same order of
magnitude and rescale them when I pass them to these routines.
Then I tried to let leastsq now only vary r_i while keeping r_s and ppw
fixed. Still, the problem pertains:

Optimizing albedo
Albedo for r_ice = 4.200000, r_soot = 1.000000, ppw = 1.000000e+00
Residual squared: 0.235837
Albedo for r_ice = 4.200000, r_soot = 1.000000, ppw = 1.000000e+00
Residual squared: 0.235837
Albedo for r_ice = 4.200000, r_soot = 1.000000, ppw = 1.000000e+00
Residual squared: 0.235837
Albedo for r_ice = 4.200000, r_soot = 1.000000, ppw = 1.000000e+00
Residual squared: 0.235837
... done. Found r_snow =  4.2

Is this still the scaling problem?

```