Re: [ROOT] Why sigma of result of gauss fit has minus value ?

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Feb 21 2002 - 10:32:07 MET


Hi Harufumi,

I cannot reproduce your problem using your data points.
See script gsigma.C in attachement.
Are you giving initial values to the function?

Which version/OS ?

Rene Brun

Harufumi Tsuchiya wrote:
> 
> Hello ROOTers !
> 
> I have following data set and I would like to fit these values
> using gaussian function.
> I could fit. But the sigma of result of fit is peculiar.
> It's value is minus.
> Why the sigma is minus ?
> Is it ordinary behevior of fitting ?
> 
> I attached ps file of result of fit.
> In the graph, p0 -> constant, p1->mean, p2->sigma.
> 
> ------ data set ---------
> -4.875000 11.2877 19.2555
> -4.625000 -1.51158 19.483
> -4.375000 28.0305 19.1328
> -4.125000 16.8634 19.4476
> -3.875000 -6.06664 19.6773
> -3.625000 17.5673 19.3519
> -3.375000 18.0013 19.2891
> -3.125000 0.0122975 19.2632
> -2.875000 -8.8495 19.2595
> -2.625000 -2.269 19.2171
> -2.375000 -1.83825 19.154
> -2.125000 -18.7014 19.1244
> -1.875000 13.1121 19.0246
> -1.625000 2.73537 19.6297
> -1.375000 -14.1883 19.448
> -1.125000 4.21429 19.2307
> -0.875000 -26.4092 19.1161
> -0.625000 -37.6974 19.2017
> -0.375000 -85.1394 19.0828
> -0.125000 -123.675 19.1227
> 0.125000 -97.6141 19.5093
> 0.375000 -61.8173 19.2825
> 0.625000 -12.6419 19.5097
> 0.875000 -22.5329 19.3263
> 1.125000 -6.85978 19.3608
> 1.375000 3.64534 19.7056
> 1.625000 17.0031 19.2862
> 1.875000 -14.6644 19.535
> 2.125000 -20.5573 18.9344
> 2.375000 5.01405 19.1549
> 2.625000 1.62057 19.3475
> 2.875000 -18.1711 19.2898
> 3.125000 -5.51773 19.3767
> 3.375000 1.84787 19.3669
> 3.625000 -8.84978 19.2802
> 3.875000 -5.60688 19.3258
> 4.125000 -13.3567 19.3979
> 4.375000 -8.71397 19.0163
> 4.625000 -25.7126 19.6368
> 4.875000 2.9404 19.0503
> 
>   --------------------------------------------------------------------------------
> 
>                     Name: fit_res.ps
>    fit_res.ps       Type: Postscript Document (Application/Postscript)
>                 Encoding: quoted-printable

Double_t fgaus(Double_t *x, Double_t *par) {
   Double_t arg = (x[0] - par[1])/par[2];
   return par[0]*TMath::Exp(-0.5*arg*arg);
}
void gsigma() {
   
   TGraphErrors *gr = new TGraphErrors(40);
   gr->SetPoint( 0,-4.875000, 11.2877);  gr->SetPointError( 0, 0, 19.2555);
   gr->SetPoint( 1,-4.625000, -1.51158); gr->SetPointError( 1, 0, 19.483);
   gr->SetPoint( 2,-4.375000, 28.0305);  gr->SetPointError( 2, 0, 19.1328);
   gr->SetPoint( 3,-4.125000, 16.8634);  gr->SetPointError( 3, 0, 19.4476);
   gr->SetPoint( 4,-3.875000, -6.06664); gr->SetPointError( 4, 0, 19.6773);
   gr->SetPoint( 5,-3.625000, 17.5673);  gr->SetPointError( 5, 0, 19.3519);
   gr->SetPoint( 6,-3.375000, 18.0013);  gr->SetPointError( 6, 0, 19.2891);
   gr->SetPoint( 7,-3.125000, 0.0122975);gr->SetPointError( 7, 0, 19.2632);
   gr->SetPoint( 8,-2.875000, -8.8495);  gr->SetPointError( 8, 0, 19.2595);
   gr->SetPoint( 9,-2.625000, -2.269);   gr->SetPointError( 9, 0, 19.2171);
   gr->SetPoint(10,-2.375000, -1.83825); gr->SetPointError(10, 0, 19.154);
   gr->SetPoint(11,-2.125000, -18.7014); gr->SetPointError(11, 0, 19.1244);
   gr->SetPoint(12,-1.875000, 13.1121);  gr->SetPointError(12, 0, 19.0246);
   gr->SetPoint(13,-1.625000, 2.73537);  gr->SetPointError(13, 0, 19.6297);
   gr->SetPoint(14,-1.375000, -14.1883); gr->SetPointError(14, 0, 19.448);
   gr->SetPoint(15,-1.125000, 4.21429);  gr->SetPointError(15, 0, 19.2307);
   gr->SetPoint(16,-0.875000, -26.4092); gr->SetPointError(16, 0, 19.1161);
   gr->SetPoint(17,-0.625000, -37.6974); gr->SetPointError(17, 0, 19.2017);
   gr->SetPoint(18,-0.375000, -85.1394); gr->SetPointError(18, 0, 19.0828);
   gr->SetPoint(19,-0.125000, -123.675); gr->SetPointError(19, 0, 19.1227);
   gr->SetPoint(20,0.125000, -97.6141);  gr->SetPointError(20, 0, 19.5093);
   gr->SetPoint(21,0.375000, -61.8173);  gr->SetPointError(21, 0, 19.2825);
   gr->SetPoint(22,0.625000, -12.6419);  gr->SetPointError(22, 0, 19.5097);
   gr->SetPoint(23,0.875000, -22.5329);  gr->SetPointError(23, 0, 19.3263);
   gr->SetPoint(24,1.125000, -6.85978);  gr->SetPointError(24, 0, 19.3608);
   gr->SetPoint(25,1.375000, 3.64534);   gr->SetPointError(25, 0, 19.7056);
   gr->SetPoint(26,1.625000, 17.0031);   gr->SetPointError(26, 0, 19.2862);
   gr->SetPoint(27,1.875000, -14.6644);  gr->SetPointError(27, 0, 19.535);
   gr->SetPoint(28,2.125000, -20.5573);  gr->SetPointError(28, 0, 18.9344);
   gr->SetPoint(29,2.375000, 5.01405);   gr->SetPointError(29, 0, 19.1549);
   gr->SetPoint(30,2.625000, 1.62057);   gr->SetPointError(30, 0, 19.3475);
   gr->SetPoint(31,2.875000, -18.1711);  gr->SetPointError(31, 0, 19.2898);
   gr->SetPoint(32,3.125000, -5.51773);  gr->SetPointError(32, 0, 19.3767);
   gr->SetPoint(33,3.375000, 1.84787);   gr->SetPointError(33, 0, 19.3669);
   gr->SetPoint(34,3.625000, -8.84978);  gr->SetPointError(34, 0, 19.2802);
   gr->SetPoint(35,3.875000, -5.60688);  gr->SetPointError(35, 0, 19.3258);
   gr->SetPoint(36,4.125000, -13.3567);  gr->SetPointError(36, 0, 19.3979);
   gr->SetPoint(37,4.375000, -8.71397);  gr->SetPointError(37, 0, 19.0163);
   gr->SetPoint(38,4.625000, -25.7126);  gr->SetPointError(38, 0, 19.6368);
   gr->SetPoint(39,4.875000, 2.9404);    gr->SetPointError(39, 0, 19.0503);
   
   TCanvas *c1 = new TCanvas("c1","c1",10,10,600,700);
   c1->SetGrid();
   gr->SetMarkerStyle(20);

   TF1 *f1 = new TF1("f1",fgaus,-4,4,3);
   f1->SetParameters(-100,0,1);
   gStyle->SetOptFit(1111);
   gr->Fit(f1);
   gr->Draw("ap");
}   



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