evelien at ster.kuleuven.ac.be
Thu Feb 17 08:29:56 CST 2005
And how about if you add your own derivatives? In the "help" it read
that when you want to use autoderiviate=0 your function should return
something like [status,y-func,pderiv], but then, the mpfit function
can't handle that, it gives me the following error: ValueError: unpack
list of wrong size. The function returns 3 things, the status, the
residuals and the derivatives, but mpfit just wants [status,f], so...
If it is ok with you, I would like to see your "litte wrapper" around
mpfit, maybe it can show me what I am doing wrong...
I am also trying the leastsq, but did not suceed to model my data (yet).
Steve Schmerler wrote:
> Evelien Vanhollebeke wrote:
>> Hi scipy-users,
>> I was wondering if anyone was using the mpfit module
>> (http://cars.uchicago.edu/software) <http://cars.uchicago.edu/software>.
>> I would really like (need) to use it, but can't get to seem the thing
>> perform as it should be. I am aware of the two messages posted in
>> this mailing list,
> that was me :)
>> and changed the two mentioned lines. I am using python 2.3.3. Maybe
>> if someone could share his/her user defined function or some other
>> hints? At first, the program just crashed on the parinfo, which is
>> not really necessary. Now I can get it run (if I don't use the
>> autoderivate=0, then it gets stuck on the "fjac" variable), but as
>> already mentioned, it doesn't iterate.
> Unfortunately I don't have my mpfit stuff at hand right now but what I
> remember doing was something like:
> import mpfit
> # read data and prepare 2 data arrays 't' and 'y'
> def func(t, x):
> - the model function
> - t -- x-axis (data)
> - x -- parameter array
> - return y-values at each t
> y_model = ...
> return y_model
> # len(t) == len(y_model) = len(y)
> def residuals(x, t = t, y = y, fjac = None):
> # I'm not sure about the fjac part, this residual function
> is # defined according to the example in the mpfit docstring
> # I think it was 0
> status = 0
> # or stauts at pos 1?
> return [status, y - func(t, x)]
> fit = mpfit.mpfit(residuals, ...)
> I don't remember the parinfo-stuff right now. I wrote a little
> "wrapper" around mpfit (insert limits in parinfo etc.). Tell me if you
> want to have a look on this.
> I also tried leastsq but it's less sophisticated than mpfit.
> In mpfit (in enorm()) you can replace
> This is faster.
> Cheers steve
>> SciPy-user mailing list
>> SciPy-user at scipy.net
More information about the SciPy-user