User defined function fitting

Hi

I am fitting a user defined function which has three file parameters and a normalization constant, to a data set. The fit comes good. But every time I change the starting values of parameters, I get different set of optimized fit parameters !! I can’ find the problem with my program ! For the same minimum chisq lot of different parameters sets can be obtained. It is very confusing. Which one to accept as the result. Since these parameters, I wan to use for further calculations, it is very frustrating. Can anyone help. My program runs as;

I am also attaching the data file. chisq is not very good for this set but has the same problem with file parameters.

#include “TCanvas.h”

#include “TROOT.h”

#include “TMath.h”

#include “TGraphErrors.h”

#include “TF1.h”

#include “TLegend.h”

#include “TArrow.h”

#include “TLatex.h”

using namespace std;

void ts()

{

TGraphErrors graph2(“pp21_7.dat”);

graph2.SetTitle(" pp21.7 GeV ");

graph2.SetMarkerStyle(kOpenCircle);

graph2.SetMarkerColor(kBlue);

graph2.SetLineColor(kBlue);

TCanvas* mycanvas = new TCanvas();

graph2.DrawClone(“APE”);

double constant;

double c; //c is gas density

double V;

double v0;

//TF1 f(“f1”,"[0](1/(TMath::Gamma(x+1)))(TMath::Power([1],x))*(TMath::Power(([2]-[3]*x),x))",2,28);

TF1 f(“f1”,"[0]((TMath::Power([1],x))(TMath::Power(([2]-[3]*x),x))/(TMath::Gamma(x+1)))",2,28);

//cout<<" x "<<x;

//the values of parameters]

//Initial values of parameters]

f.SetParNames(“constant”,“n”,“V”,“v0”);

f.SetParameter(0,1);// normalization constant

f.SetParameter(1,.6); // n

f.SetParameter(2,26.643); // V

f.SetParameter(3,.31);//v0

//f.DrawClone(“Same”);

f.SetLineColor(kRed);f.SetLineStyle(9);

graph2.Fit(&f);

f.DrawClone(“Same”);

//}

}

int main( )

{

ts();

return 0;

// Data set

2 .0969 00 .0108

4 .1849 00 0.0086

6 .1886 00 0.0077

8 .1707 00 0.0059

10 .1429 00 0.0049

12 .1040 00 0.0043

14 .0522 00 0.0031

16 .0352 00 0.0025

18 .0142 00 0.0019

20 0.0065 00 0.0012

22 0.0026 00 0.0009

24 0.0009 00 0.0004

26 0.0004 00 0.0003

28 0.0002 00 0.0002


Manjit Kaur email : Manjit.Kaur@cern.ch
Professor manjit@pu.ac.in
Center of Advanced Study
Department of Physics Phone # +91-172-2546173 ®
Panjab University +91-172-2534492 (O)
Chandigarh-160014 Cell # 09464683959
India


Hi,

Can you add the running program as attachment to the post and include also the data file so we can understand better your problem ?

Best Regards

Lorenzo

Hi I am attaching the running program and the data file.tsally.cxx (1017 Bytes)op161.dat (589 Bytes)

Try with: TF1 f("f", "[0] * TMath::Power(([1] - [2] * x), x) / TMath::Gamma(x + 1.0)", 1, 100); f.SetParNames("c", "nV", "nV0"); f.SetParameter(0, 2.6e-7); // c (normalization constant) f.SetParameter(1, 11); // nV (= n * V) f.SetParameter(2, -0.25); // nV0 (= n * V0) f.SetLineColor(kRed); f.SetLineStyle(9); graph2.Fit(&f, "ME");

Dear pepe
Thanks a lot. The program works well now. The parameters are calculated irrespective of the starting values.
Thanks a lot