elcorto at gmx.net
Thu Feb 17 12:37:03 CST 2005
Evelien Vanhollebeke wrote:
> And how about if you add your own derivatives?
I don't supply my own derivs so I'm arrfaid I can't help you on this point.
> 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...
OK, no problem, on Monday :)
> I am also trying the leastsq, but did not suceed to model my data (yet).
leastsq isn't bad and even a little faster since is uses the underlying
MINPACK while mpfit in pure (though using Numeric heavily) Python.
I use mpfit only because you can easily set parameter bounds. Of course
using leastsq you could build some "penalty" into func which causes it
to return very high residuals if the parameter array violates any limit
> 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
> SciPy-user mailing list
> SciPy-user at scipy.net
There are three types of people in this world: those who make things
happen, those who watch things happen and those who wonder what
happened. - Mary Kay Ash
More information about the SciPy-user