Hi all,
I have a quetion about the fit of data point with errors.
I have 5 values and errors of y and 5 values and errors of x.
These point follow the function y=a*x - b/x and I want to find the values of a and b.
In the forum I found another topic with a link to:
root.cern.ch/root/htmldoc/TGraph.html#TGraph:Fit
I created a TGraphErrors and I fitted with the my function, but I obtain, for a and b, the values of the initial condition.
This is the code:
[code] {
TCanvas *c1 = new TCanvas(“c1”,“CLT”,200,10,700,500);
Int_t n=5;
Double_t y[n]={-4.04,-2.74,-1.15,1.49,6.873};
Double_t error_y[n]={0.50,0.25,0.08,0.09,1.90};
Double_t x[n]={22000.0,22930.0,23880.0,25130.0,26390.0};
Double_t error_x[n]={440.0,470.0,500.0,530.0,540.0};
TGraphErrors *gr1 = new TGraphErrors(n,x,y,error_x,error_y);
TF1 *fit = new TF1(“fit”,"([0]*x) - ([1]/x)",21000,27000);
fit->SetParName(0,“a1”);
fit->SetParName(1,“a2”);
fit->SetParameter(0,1);
fit->SetParameter(1,1);
gr1->Fit(“fit”);
gr1->Draw(“AP”);
c1->Update();
}
[/code]
Where is my error?
Thank you
Ciccio