Fitting with Lognormal function

Dear All,

         I want to fit a distribution with Lognormal function. I have attached the distribution with this message. I have found the function.

TF1 *g1 = new TF1(“logNormal”,“ROOT::Math::lognormal_pdf(x,[0],[1])”,0,5);
// set the lognormal parameters (m and s)
// g1->SetParameters(2,0.7,10);
// g1->SetNpx(10000);

But setting the three parameters is non-trivial and its like hit and trial method. Is the method correct and is there any convenient way to set the three parameters ?

Thanks and Regards


Before fitting, you can obtain an estimate of the log normal parameters from the mode and the median of the data distribution you observe (i.e. your histogram).
An example is in the attached macro. Look also at for the log-normal definitions (mode, median, etc…)

Often it is used also a different parametrisation of the log-normal (more physics oriented) in term of a parameter m = exp(mu) and k = exp(sigma), where m is the median of the distribution and k-1 corresponds to something like a “relative uncertainty”.
In this case you define your fit function as

TF1 *f1 = new TF1(“logNormal”,"[0]*ROOT::Math::lognormal_pdf(x,log([0]),log([1]))",0,5);

If you want to know more, I suggest you to look at this note by B. Cousins, … _prior.pdf

Best Regards

lognormal_fit.C (1.44 KB)

1 Like