Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!news.dfncis.de!not-for-mail From: =?ISO-8859-1?Q?Hans-Bernhard_Br=F6ker?= Newsgroups: comp.graphics.apps.gnuplot Subject: Re: FIT A DATAFILE THROUGH ANOTHER DATAFILE Date: Mon, 11 Jun 2012 21:28:54 +0200 Lines: 26 Message-ID: References: <3c8bd4d3-6360-4e6b-b830-09db7c44bf46@5g2000vbf.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.dfncis.de 7GjyxYFfCrByCd2NUl/EgAPWtzwWW5BI+rMyrDSTecQydLy2ce4LXAWQ5/4aDTcjboBPM4/EsG Cancel-Lock: sha1:yo2P6lWu8AOf4VeZI8YcMTrpZcU= User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20120420 Thunderbird/12.0 In-Reply-To: <3c8bd4d3-6360-4e6b-b830-09db7c44bf46@5g2000vbf.googlegroups.com> Xref: csiph.com comp.graphics.apps.gnuplot:1199 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