Hi Nicolas, You sent two related mails and I replied to your second mail. See http://root.cern.ch/root/roottalk/roottalk02/3902.html The difference between the interpreted function and the predefined functions was in the computation of the range. This is now fixed thanks to your suggestion in Root version 3.03/09 now available on our Web site. Rene Brun On Wed, 18 Sep 2002, Nicolas de Sereville wrote: > Hi rooters, > > I wrote to the mailing list last week and didn't receive answer (see link) > http://root.cern.ch/root/roottalk/roottalk02/3887.html > So I tried to make a more understandable example (see code at the end). > > I noticed a strange behaviour while fitting TGraphErrors with a user > function. > In the following example, I define a TGraphError with horizontal an > vertical error bars. When I use the predefined function, the fit is good > and takes into account the horizontal error bars. When I use my user > function, I can see that the fit result is not the same and correspond to > the case without the x error bars!! > > Am I doing something wrong? > > Thanks > > Nicolas (root 3.02/03 on RH 7.1) > > > > void test() > { > gStyle->SetOptFit(1); > > Double_t x[3] = {1, 2, 3}; > Double_t ex[3] = {0.1, 0.1, 0.1}; > Double_t y[3] = {1, 2.1, 2.9}; > Double_t ey[3] = {0.1, 0.1, 0.1}; > > TGraphErrors *gre = new TGraphErrors(3, x, y, ex, ey); > // TGraphErrors *gre = new TGraphErrors(3, x, y, 0, ey); > gre->Draw("A*"); > > // predefined function > TF1 *f1 = new TF1("f1", "pol1", 0, 4); > gre->Fit("f1", "R"); > > // user function > // TF1 *fitf = new TF1("fitf", fitf, 0, 4, 2); > // fitf->SetParameters(0.1, 1); > // fitf->SetParNames("b", "a"); > // gre->Fit("fitf", "R"); > } > > > Double_t fitf(Double_t *x, Double_t *par) > { > return par[0] + par[1]*x[0]; > } > > -- > :-------------------------------: > : Nicolas DE SEREVILLE : > : C.S.N.S.M. : > : Batiment 104 : > : 91405 ORSAY Campus : > : Tel : (+ 33) (0)1 69 15 48 57 : > : Fax : (+ 33) (0)1 69 15 50 08 : > :-------------------------------: >
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:10 MET