Re: [ROOT] Problems with fiting

From: Eddy Offermann (eddy@rentec.com)
Date: Mon Sep 30 2002 - 16:25:27 MEST


Hi,

Some observations:

1) when specifying errors in x, your fit becomes non-linear in the parameters !!
   Specifying 'W' option makes it a linear fit
2) Your data weights are very "challenging: do you really think
    specifying y[6] is important when neighboring data points
    y[4] and y[5] have each
    a weight in the fit that is 2500 times larger ?
3) Your fit returns with the message that the matrix was not
   positive-definite (probably related to 2) ), so results can
   not be trusted.
   
Rene, I tried to play around with the scripts by fixing some parameters:

  TF1 f1("f1","pol2");
  f1.FixParameter(0,-3.22);
  f1.FixParameter(1,0.349);
  f1.SetParameter(2,-6.93469e-08);
  graph->Fit("f1","LEM");
  
The parameters are indeed fixed but not at the expected values ??

Eddy

> X-Authentication-Warning: pcroot.cern.ch: majordomo set sender to 
owner-roottalk@root.cern.ch using -f
> Date: Mon, 30 Sep 2002 12:06:03 +0200 (MET DST)
> From: Alexander Dietz <adietz@mickey.mpi-hd.mpg.de>
> To: root list <roottalk@pcroot.cern.ch>
> Subject: [ROOT] Problems with fiting
> MIME-Version: 1.0
> 
> Hello Rooters,
> 
> I have a problem with doing a fit with a TGraphErrors. In the program
> source (at the end of this mail) I want to perform a quadratic fit with
> 'TGraphErrors", using the errors as specified.
> When I use the fitting option 'W' (all errors set to 1) then the fit works
> very good, giving a sensefull result.
> But without the option 'W' the result of the fit is very, very bad and
> wrong.
> The correct result is, that parameter 1 is about 0.35.
> But with the option 'W' this parameter is around 10^7 !!!
> 
> So what can I do to get a correct fit which is using the errors I have
> specified?
> 
> 
> Regards
> 
> 	Alexander Dietz
> 
> 
> void prog(void)
> {
>   float x[10];
>   float y[10];
>   float ex[10];
>   float ey[10];
> 
>   x[0]= 7508.84 ;ex[0]=0.037;
>   x[1]= 1680.41 ;ex[1]=0.022 ;
>   x[2]= 2093.11 ;ex[2]=0.05 ;
>   x[3]= 2259.89 ;ex[3]=0.157;
>   x[4]= 2474.87 ;ex[4]=0.065;
>   x[5]= 2569.45 ;ex[5]=0.473;
>   x[6]= 3100.43 ;ex[6]=0.272;
>   x[7]= 4574.82 ;ex[7]=0.147;
>   x[8]= 6041.46 ;ex[8]=0.15 ;
> 
>   y[0]=2614.53 ;ey[0]=0.013;
>   y[1]=583.191 ;ey[1]=0.002;
>   y[2]=727.33  ;ey[2]=0.009;
>   y[3]=785.37  ;ey[3]=0.08;
>   y[4]=860.564 ;ey[4]=0.005;
>   y[5]=893.40  ;ey[5]=0.005;
>   y[6]=1078.62 ;ey[6]=0.1;
>   y[7]=1592.54 ;ey[7]=0.013;
>   y[8]=2103.53 ;ey[8]=0.013;
> 
> 
>   TCanvas* c1=new TCanvas("c1","c1",10,10, 400,300);
>   TGraphErrors* graph=new TGraphErrors(9,x,y,ex,ey);
> 
>   graph->Draw("A*");
>   graph->Fit("pol2","LEM");
>   graph->Draw("");
> 
>   double p0=graph->GetFunction("pol2")->GetParameter(0);
>   double p1=graph->GetFunction("pol2")->GetParameter(1);
>   double p2=graph->GetFunction("pol2")->GetParameter(2);
> }
> 
> 

Eddy A.J.M. Offermann
Renaissance Technologies Corp.
Route 25A, East Setauket NY 11733
e-mail: eddy@rentec.com
http://www.rentec.com



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:12 MET