Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.graphics.apps.gnuplot > #365

Re: trying to get a fit to work.

From sfeam <sfeam@users.sourceforge.net>
Newsgroups comp.graphics.apps.gnuplot
Subject Re: trying to get a fit to work.
Followup-To comp.graphics.apps.gnuplot
Date 2011-06-08 21:48 -0700
Organization gnuplot development team
Message-ID <ispja4$fmf$1@dont-email.me> (permalink)
References <62b76acf-a50c-49f2-a02a-908398651e5b@q12g2000prb.googlegroups.com>

Followups directed to: comp.graphics.apps.gnuplot

Show all headers | View raw


aviphysics wrote:

> So I got this HPLC peak that I am trying to fit a exponentialized
> Gaussian to. It fits decently in Mathematica but trying to fit it in
> gnuplot yields "Undefined value during funtion evaluation"
> 
> The equation is
> modeltwo(x) = 1/(2*tau)*exp(sigma**2/(2*tau**2)-(x-em)/
> tau)*erfc(sigma/
> (sqrt(2)*tau)-(x-em)/(sqrt(2)*sigma))
> 
> Here is a plot using the starting constants
> http://i283.photobucket.com/albums/kk302/keyserthomas/plot.jpg
> 
> em=10
> sigma=2.3
> tau=4.98
> 
> Any ideas what the problem might be?

I forwarded this to a colleague, who replied:

%%%%%%%%%%%%%%%%

I tried a few more experiments and found that:

                 Windows           Linux (or at least Porlock)
                ---------         -------
erfc(x)      fails for |x|>~20    works (goes from -2 to 0)
erf(x)       works                works (both go from -1 to 1)
exp(x)       overflows            overflows - both at exp(~700) = 1.2x10^307

Neither OS underflows with exp(-x) - both go to zero.
I think this means there's something wrong with the way erfc works in 
windows, other than basic underflow handling. So an even simpler fix uses 
the definition of erfc:

myerfc(x) = 1 - erf(x)

- Frank

%%%%%%%%%%%%%%%%%%

So I looked at the code and found that if the configuration tool detects
erfc() in the standard libraries, the program uses it.  If not, there is
an internal implementation.  I am guessing that you are using a machine
that has configured in the internal version, and there is an overflow bug
in it somewhere.  That should be fixable, but for now you use the
workaround above.

Back to comp.graphics.apps.gnuplot | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

trying to get a fit to work. aviphysics <aviphysics@gmail.com> - 2011-06-07 16:32 -0700
  Re: trying to get a fit to work. Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2011-06-08 23:02 +0200
  Re: trying to get a fit to work. sfeam <sfeam@users.sourceforge.net> - 2011-06-08 21:48 -0700
    Re: trying to get a fit to work. Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2011-06-09 22:26 +0200
      Re: trying to get a fit to work. sfeam <sfeam@users.sourceforge.net> - 2011-06-09 18:29 -0700

csiph-web