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


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

Re: FIT A DATAFILE THROUGH ANOTHER DATAFILE

From Hans-Bernhard Bröker <HBBroeker@t-online.de>
Newsgroups comp.graphics.apps.gnuplot
Subject Re: FIT A DATAFILE THROUGH ANOTHER DATAFILE
Date 2012-06-11 21:28 +0200
Message-ID <a3mv7nFtltU1@mid.dfncis.de> (permalink)
References <3c8bd4d3-6360-4e6b-b830-09db7c44bf46@5g2000vbf.googlegroups.com>

Show all headers | View raw


On 11.06.2012 15:27, Roberto Guerra IDV Novi wrote:

> I have a curve in a datafile that is supposed to be the weighted sum
> of other two curves. I wish to find the coefficients for such sum so
> that curve1=curve2*a+curve3*b.
> I tried with the following fit:
>
>   fit 0.0 "<  paste curve1.dat curve2.dat curve3.dat" u 1:($2-$4*a-$6*b)
> via a,b

That cannot work, because gnuplot fits functions, not data.

What that means is that the parameters to be fitted have to appear in 
the _function_ you specify, not in the data's 'using' specification. 
The deeper reason is that gnuplot will not re-read all your data for 
every iteration of the fit.  So the data 'fit' actually sees are built 
with the initial values of 'a' and 'b', and never change after that.  So 
you're trying to 'fit' a constant to a constant.  No wonder that there's 
no result.

A fit that just might work would be:

    fit a*x+b*y \
      "< paste curve1.dat curve2.dat curve3.dat" \
       u 4:6:2:(1.0) \
      via a, b

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


Thread

FIT A DATAFILE THROUGH ANOTHER DATAFILE Roberto Guerra IDV Novi <cipitaua@gmail.com> - 2012-06-11 06:27 -0700
  Re: FIT A DATAFILE THROUGH ANOTHER DATAFILE Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2012-06-11 21:28 +0200

csiph-web