[SciPy-User] leastsq (probably simple) question

Pierre Barbier de Reuille pierre@barbierdereuille....
Mon Feb 25 10:53:16 CST 2013


And did you check how many evaluations are made?

It's in the 'nfev' element of the infodict if you ask for the full output.

-- 
Barbier de Reuille Pierre


On 25 February 2013 16:56, Kevin Gullikson <kevin.gullikson.signup@gmail.com
> wrote:

> I have tried playing with xtol and ftol, even pushing them all the way to
> 10, but it doesn't seem to have any effect.
>
>
> On Mon, Feb 25, 2013 at 9:50 AM, <josef.pktd@gmail.com> wrote:
>
>> On Sun, Feb 24, 2013 at 9:40 PM, Kevin Gullikson
>> <kevin.gullikson@gmail.com> wrote:
>> > Hey all,
>> >
>> > I am trying to use scipy.optimize.leastsq to do a one-parameter fit. The
>> > final result is not very sensitive to the exact value, so I am
>> wondering how
>> > you can limit leastsq to stop iterating once the values it is testing
>> are
>> > reasonably close together? Example output from my code:
>> >
>> > Resolution-fitting X^2 =  1056.95654172 at R =  [ 51908.71176496]
>> > Resolution-fitting X^2 =  1054.42705462 at R =  [ 51908.71170349]
>> > Resolution-fitting X^2 =  1054.42705427 at R =  [ 51908.71174447]
>> > Resolution-fitting X^2 =  1056.95654172 at R =  [ 51908.71176496]
>> > Resolution-fitting X^2 =  1056.95654172 at R =  [ 51908.71176496]
>> > Resolution-fitting X^2 =  1054.42705436 at R =  [ 51908.71173423]
>> > Resolution-fitting X^2 =  1056.95654181 at R =  [ 51908.71175472]
>> > Resolution-fitting X^2 =  1054.42705431 at R =  [ 51908.71173935]
>> > Resolution-fitting X^2 =  1054.42705427 at R =  [ 51908.71174447]
>> > Resolution-fitting X^2 =  1054.42705427 at R =  [ 51908.71174447]
>> > Resolution-fitting X^2 =  1054.42705427 at R =  [ 51908.71174447]
>> > Resolution-fitting X^2 =  3408043.11138 at R =  [ 216058.47126214]
>> > Resolution-fitting X^2 =  1054.8705442 at R =  [ 51857.89239384]
>> > Resolution-fitting X^2 =  1054.64687339 at R =  [ 51883.47239909]
>> > Resolution-fitting X^2 =  1054.53612148 at R =  [ 51896.17634439]
>> > Resolution-fitting X^2 =  1054.48119765 at R =  [ 51902.48582026]
>> > Resolution-fitting X^2 =  1054.4539391 at R =  [ 51905.61951157]
>> > Resolution-fitting X^2 =  1054.44040558 at R =  [ 51907.1759188]
>> > Resolution-fitting X^2 =  1054.4336851 at R =  [ 51907.9489416]
>> > Resolution-fitting X^2 =  1054.43034753 at R =  [ 51908.33288072]
>> > Resolution-fitting X^2 =  1054.42868992 at R =  [ 51908.52357292]
>> > Resolution-fitting X^2 =  1054.42786665 at R =  [ 51908.61828465]
>> > Resolution-fitting X^2 =  1054.42745775 at R =  [ 51908.66532545]
>> > Resolution-fitting X^2 =  1054.42725467 at R =  [ 51908.68868937]
>> > Resolution-fitting X^2 =  1054.4271538 at R =  [ 51908.70029361]
>> > Resolution-fitting X^2 =  1054.4271037 at R =  [ 51908.70605713]
>> > Resolution-fitting X^2 =  1054.42707882 at R =  [ 51908.70891972]
>> > Resolution-fitting X^2 =  1054.42706646 at R =  [ 51908.71034149]
>> >
>> > The parameter I am adjusting is R (the resolution of a spectrograph),
>> and as
>> > you can see it is doing these tiny changes which have very little
>> affect on
>> > the X^2 value (that is not reduced X^2, so don't worry that it isn't
>> near
>> > 1!)
>> >
>> > Is there a way to tell leastsq to stop once it gets to say 51908 (in
>> this
>> > example)?
>>
>> rescale your function and/or parameters or reduce xtol and ftol
>> 1e-8 will be too small if your values are large
>>
>> Josef
>>
>> >
>> > Kevin Gullikson
>> >
>> > _______________________________________________
>> > SciPy-User mailing list
>> > SciPy-User@scipy.org
>> > http://mail.scipy.org/mailman/listinfo/scipy-user
>> >
>> _______________________________________________
>> SciPy-User mailing list
>> SciPy-User@scipy.org
>> http://mail.scipy.org/mailman/listinfo/scipy-user
>>
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20130225/ad78f128/attachment.html 


More information about the SciPy-User mailing list