[SciPy-User] Alternatives to scipy.optimize

Kevin Gullikson kevin.gullikson at gmail.com
Sat Feb 25 14:31:55 EST 2012


Erik,

You can do the least-squares fit to func2 within the function that you pass
to scipy.optimize.leastsq (or similar).
For fixed parameters, I use a second array called const_pars, and pass it
to leastsq as one of the arguments (e.g. leastsq(ErrFunc, pars,
args=(const_pars)) ) For example:

def func1(p1):
  //some non-linear function of p1

def func2(p2):
  //some linear function of p2

def ErrFunc(p1,p2):
  //Do linear fit to func2 and optimize parameters p1

  return func1(p1) + func2(p2)

//Run leastsq:
pars, success = scipy.optimize.leastsq(ErrFunc, p1, args=(p2))

Hope that helps!

Kevin Gullikson



On Sat, Feb 25, 2012 at 1:17 PM, Erik Petigura <eptune at gmail.com> wrote:

> Dear Scipy,
>
> Up until now, I've found the optimize module very useful.  Now, I'm
> finding that I need finer control.  I am fitting a model to data that is of
> the following from:
>
> model = func1(p1) + func2(p2)
>
> func1 is nonlinear in its parameters and func2 is linear in its
> parameters.
>
> There are two things I am struggling with:
>
> 1. I'd like to find the best fit parameters for func1 using an iterative
> approach (e.g. simplex algorithm that changes p1.).  At each iteration, I
> want to compute the optimum p2 by linear least squares in the interest of
> speed and robustness.
>
> 2. I'd also like the ability to hold certain parameters fixed in the
> optimization with out redefining my objective function each time.
>
>
> Is there another module you would recommend?  I've found openopt, but I
> wanted to get some guidance before I dive in to that.
>
> Erik
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at 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/20120225/1f1c4022/attachment.html>


More information about the SciPy-User mailing list