Re: Fit x,y [2]

From: Valery Fine (fine@mail.cern.ch)
Date: Sun Aug 10 1997 - 16:27:53 MEST


On 10 Aug 97 at 13:27, Voropaev S.G. wrote:


> Hi,
> I investigate my problem. New example:
> 
> float x[20], y[20];
> for(int i=0; i<20; i++) {x[i]=(i+1)/21.0; y[i]=0.5*x[i]+0.2;};
> c1 = new TCanvas("c1","proba");
> TGraph *tg = new TGraph(20,x,y);
> tg->Draw("AP");
> tg->Fit("pol1");		// All is OK. I see all my point and long line.
> 
> for(int i=0; i<20; i++) {x[i]=gRandom->Rndm(1); y[i]=0.5*x[i]+0.2;};
> delete tg; TGraph *tg = new TGraph(20,x,y); tg->Draw("AP");
> tg->Fit("pol1");	
> 
> Now I see all my point and very short line. The X range of line is
> 0.1-0.2!

  But did you see you the graphic view properly ? 
  You may say "yes" but I'll insist "no". That's because of the 
shape of your function special function:  0.5*x + 0.2, Change your 
function to something else and draw it and WITH APL options to 
see the REAL its shape. (For example 0.5*x**2 + .2). No ask some 
human (not computer)  to fit that "by hand".

> 
> Question: Can I  fit non-sorted x,y data point?
> 

  No one has to sort it first. Otherwise I have no idea how to fit 
the data supplied even myself (and even it is the straight line).
 Otherwise one needs the third array to define the order of his 
points explicitly just to allow TMinuit class to sort his data.

  Wiht my regards,
                Valery
=================================================================
Dr. Valery Fine                  Telex : 911621 dubna su
    -----------
LCTA/Joint Inst.for NuclearRes   Phone : +7 09621 6 40 80
141980 Dubna, Moscow region      Fax   : +7 09621 6 51 45
Russia                           mailto:fine@main1.jinr.dubna.su                              

Dr. Valeri Faine
    ------------                 Phone: +41 22 767 6468
CERN                             FAX  : +41 22 767 7910
CH-1211 Geneva, 23               mailto:fine@mail.cern.ch 
Switzerland                      http://nicewww.cern.ch/~fine
                                 



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:20 MET