![](https://secure.gravatar.com/avatar/ac4e2152839c56c5326cd95ae54296e9.jpg?s=120&d=mm&r=g)
On Sun, Oct 19, 2008 at 10:37 AM, Maximilian Fabricius <mxhf@gmx.net> wrote:
Hello,
I have been using scipy for about one and a half years now and have been extremely pleased.
In this time I have made extensive use of scipy.optimize.leastsq. While I am generally fairly happy with its performance, I think it does lacks one important feature which I am used to from similar routines in other languages. (Please excuse if I have just missed that feature so far.)
I would like to be able to control which parameters actually are fitted. For example I would like to be able to do
leastsq( redsiduals, p0, args=(y), fit=([True,True,False,True]) )
where the parameter "fit" would tell leastsq to leave the parameter p0[2] untouched while fitting the others.
I think you can do this by 'wrapping' your existing function: Something like: fit_function = lambda x, fixed: residuals(x[0],x[1],fixed[0],x[2]) Then you can call least squared with the fixed argument specified leastsq( fit_function, p0, args=(y,fixed)) You can either have the fixed parameters passed as a argument to the lambda, or have them defined where the lambda is run (but I find it a bit confusiong becuase the scoping gets funny). I'm sure you could do something to get the [True, False] type notation you want - but since you will have to specify the fixed values as well. Robin