[SciPy-user] Re: SciPy-user Digest, Vol 22, Issue 3

John Hunter jdhunter at ace.bsd.uchicago.edu
Tue Jun 28 09:32:42 EDT 2005


>>>>> "aurelien" == aurelien gourrier <aurelien.gourrier at free.fr> writes:

    aurelien> Hi all, Can anyone tell me if there is a possibility to
    aurelien> use constraints on the leastsq method ? I need to do
    aurelien> some bounded minimization of gaussians or lorentzians on
    aurelien> 1-D data and couldn't find any way out so far...


scipy.optimize.fmin_l_bfgs_b takes an optional bounds argument, which
is a list of min/max values for each parameter, and you can use None
to specify unbounded, eg 

  guess = 1.0, -.4, 0.01  
  bounds = [ (0., 4.), (None, 0.), (0., .2) ]
  best, val, d = fmin_l_bfgs_b(func, guess, bounds=bounds)

JDH




More information about the SciPy-User mailing list