Hi Harufumi, The default TRandom is not good enough for your test. Do the following instead: TRandom3 r; for ( Int_t i = 0; i < 10000; i++) { for ( Int_t j = 0; j < npars; j++ ) { lx[j] = r.Rndm(i); x[j] = 10**lx[j]; lq += lx[j]; } q = 10**lq; // cout << q << " " << lq << endl; hl->Fill(lq); hl2->Fill(q); lq = 0.0; } Rene Brun On Fri, 14 Jun 2002, Harufumi Tsuchiya wrote: > > Hi ROOTers, > > I would like to fit the data using lognormal distributiuon and > I wrote attached macro. > > But, I alwasy got failure until I try to fit 3 times. > As shown below, in 3 times, I got something good results. > > However, if I change value of npars, which is argument of macro, > for example, to 4 or 2, I succeeded in fitting the histogram a time. > > Why ? > I use ROOT v 3.03/05 and g++ 2.95.2 on IRIX 64. > > Harufumi Tsuchiya > > -------------------------------------------------------- > root [0] .x LogNormal2.cpp() <------ (first try) > 200 > FCN=8096.26 FROM MIGRAD STATUS=CONVERGED 555 CALLS 556 TOTAL > EDM=2.13927e-07 STRATEGY= 1 ERR MATRIX NOT POS-DEF > EXT PARAMETER APPROXIMATE STEP FIRST > NO. NAME VALUE ERROR SIZE DERIVATIVE > 1 p0 1.02155e+01 3.06869e+00 1.02872e-02 -2.64182e-03 > 2 p1 8.28982e+05 3.63901e+07 2.54515e+02 2.29469e-10 > 3 p2 9.99117e+06 9.57300e+07 2.54515e+02 -1.94306e-11 > Chi2 and dof = 8096.26 184 <---- wrong !!!!!!!!!!!!!!!!!!!!!! > Probability 0 > root [1] .x LogNormal2.cpp() <------- (second try) > Warning in <TH1::Build>: Replacing existing histogram: hl (Potential memory leak). > Warning in <TH1::Build>: Replacing existing histogram: hl2 (Potential memory leak). > 200 > FCN=8019.71 FROM MIGRAD STATUS=CONVERGED 508 CALLS 509 TOTAL > EDM=1.11024e-07 STRATEGY= 1 ERR MATRIX NOT POS-DEF > EXT PARAMETER APPROXIMATE STEP FIRST > NO. NAME VALUE ERROR SIZE DERIVATIVE > 1 p0 1.10649e+01 2.78345e+00 1.08733e-02 -1.87808e-03 > 2 p1 8.72864e+06 4.67588e+07 2.53309e+02 1.32604e-10 > 3 p2 3.70683e+07 2.19576e+08 2.53309e+02 -3.13716e-11 > Chi2 and dof = 8019.71 181 <---- wrong !!!!!!!!!!!!!!!!!!!!!! > Probability 0 > root [2] .x LogNormal2.cpp() <----- (third try) > Warning in <TH1::Build>: Replacing existing histogram: hl (Potential memory leak). > Warning in <TH1::Build>: Replacing existing histogram: hl2 (Potential memory leak). > 200 > FCN=199.661 FROM MIGRAD STATUS=CONVERGED 469 CALLS 470 TOTAL > EDM=1.99527e-07 STRATEGY= 1 ERROR MATRIX UNCERTAINTY 2.2 per cent > EXT PARAMETER STEP FIRST > NO. NAME VALUE ERROR SIZE DERIVATIVE > 1 p0 1.18611e+02 1.45605e+00 1.39037e-02 -1.25445e-04 > 2 p1 1.49387e+00 5.31796e-03 -7.32891e-06 -1.45410e-01 > 3 p2 4.96796e-01 3.59119e-03 -3.15101e-05 -9.75802e-02 > Chi2 and dof = 199.661 185 <---- something good !! > Probability 0.21847 > ----------------------------------------------------------------------------------- > >
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:57 MET