Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

exponential decay fit problem

2,542 views
Skip to first unread message

Karl Ratzsch

unread,
Jan 27, 2010, 11:40:13 AM1/27/10
to
Hello,

fitting a function like

f(x) = A * exp(-x/t) + b

, the fit sometimes just stops saying "undefined value during function
evaluation". The last set of parameters shown looks OK, but if i enter

print t

, t has a different value, of opposite sign. Returning it to the old
value, and then plotting data and function, shows the old values to be a
reasonable starting points to the fitting, actually fitting quite well.

This happens sporadically with certain datasets, that don´t differ
significantly (as i see) from the ones measured before and after. (i
sample a lot of datasets, which deviate only on a large timescale).

The problem goes away with different starting points, but as i always
take the ones from the last fit, the problem is reproducible.

If needed i could supply such a dataset, but as they´re rather big, i
wanted to ask before, if anybody knows this behavior?

Greetings,
Karl

Dan Luecking

unread,
Jan 27, 2010, 12:06:42 PM1/27/10
to
On Wed, 27 Jan 2010 17:40:13 +0100, Karl Ratzsch <mail...@gmx.net>
wrote:

>Hello,
>
>fitting a function like
>
>f(x) = A * exp(-x/t) + b

I know almost nothing about how gnuplot's fit is done, but
your f(x) is extremely unstable near t=0. The exponential
will be near 0 if x/t is positive and t near 0, but extremely
large if x/t is negative and t near 0. Only if it is known
that t is not too small _and_ you give some hint of this
(with a good starting value, perhaps) will you be certain
of a decent result.

It would almost certainly be better to replace t by 1/s and
fit
f(x) = A * exp (-s*x) + b
instead. Here small values of t become large values of s.
Gnuplot will never be dividing by 0 (or small values) and
most algorithms will quickly reject cases where s*x is
negative and large enough for potential overflow.

>, the fit sometimes just stops saying "undefined value during function
>evaluation".

Probably either x/t with t=0, or an overflow of exp (-x/t) when
x/t is negative and t small.

>If needed i could supply such a dataset, but as they�re rather big, i
>wanted to ask before, if anybody knows this behavior?

Similar problems have been reported before. I think it has
always been explained as being the nature of the fitting
algorithm and the instability of the fitted function.


Dan
To reply by email, change LookInSig to luecking

Hans-Bernhard Bröker

unread,
Jan 27, 2010, 2:24:40 PM1/27/10
to
Karl Ratzsch wrote:
> fitting a function like
>
> f(x) = A * exp(-x/t) + b
>
> , the fit sometimes just stops saying "undefined value during function
> evaluation". The last set of parameters shown looks OK, but if i enter
>
> print t
>
> , t has a different value, of opposite sign.

That sign change is most likely the root problem. It turned
exp(-large_number), which is zero, into exp(+large_number), which is out
of range. Thus the undefined value during function evaluation, and
there's not really any way for fit to continue from there. It basically
ran into a wall.

But if fit found a complete flip of the sign helpful, you've probably
run into other numerical limitations before. E.g. the "parameters had
better be of similar magnitude" one.

> Returning it to the old
> value, and then plotting data and function, shows the old values to be a
> reasonable starting points to the fitting, actually fitting quite well.

Reasonable doesn't really mean anything... plots of exponential decays
are notoriously deceptive as far as judging fit quality goes. You would
plot of the residuals

(y[i] - f(x[i]))/sigma_y[i]

to see what's really going on.

0 new messages