Hello all,
I am struggling to fit a function.having four parameters to a set of 5 data points
The key issue I am trying to resolve is the abnormally hight chi^2 value of 845
The minimizer is Minuit / Migrad
Chi2 = 845.817
NDf = 1
Edm = 2.51652e-07
NCalls = 77
p0 = -25071.4 +/- 24111.9
p1 = -16.4008 +/- 169.97
p2 = -0.0503403 +/- 0.37486
p3 = 1673.53 +/- 1079.4
Fit is valid!
Fit Status:0
Can someone please help in improving the fit quality and reducing he chi^2 ?Here is the macro if it helps
void fit(){
gStyle->SetEndErrorSize(4.0);
TCanvas *c1 = new TCanvas("c1","c1",800,800);
const int n = 5;
double x[n]= {244.1, 444, 867, 1005, 1213};
double y[n]= {0, 437, 787, 803, 895};
double err_y[n] = {0, 3, 2, 7, 4};
TF1 *func = new TF1("fitf","[3] + [2]*x + [0]/TMath::Sqrt(x + [1])", 0, 1400);
func->SetParameter(0, -25071);
func->SetParameter(1, -16.399);
func->SetParameter(2, -0.050344);
func->SetParameter(3, 1673.55);
func->SetLineWidth(1);
auto g = new TGraphErrors(n,x,y,nullptr, err_y);
g->SetMarkerStyle(7);
g->SetMarkerSize(3);
g->SetLineWidth(2);
TFitResultPtr r = g->Fit(func, "WRS");
//Fit Validity
Int_t fitStatus = r;
if (r->IsValid()) std::cout << "Fit is valid!" << std::endl;
else std::cout << "Fit is not valid!" << std::endl;
cout << "Fit Status:" << r << endl;
g->Draw("AP");
g->GetXaxis()->SetRangeUser(200, 1400);
g->GetYaxis()->SetRangeUser(-20, 1000);
gStyle->SetOptFit(111);
}
Thanks a lot for your time and considertaion