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); }
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:11 MET