Clarifying a user defined function (skewed gaussian)

Hello,

I am trying to figure out how to use a skewed gaussian to fit my data. In the process of searching for how to implement this in root, I came across the following resource that seems relevant, but I am unsure about one thing.

Resource:
https://root.cern.ch/root/roottalk/roottalk04/att-2524/01-fnc.C

My question:
What does (x<[1]) do in the following line?

TF1 *sgf = new TF1("sgf","[0]*exp(-0.5*pow((x-[1])/([2]+(x<[1])*[3]*(x-[1])),2))");

Does anyone have a better recommendation of how to implement a skewed gaussian?

Thank you very much for your help!

Perhaps @moneta can help.

1 Like

Hi,

I don’t think what provided there is a good implementation. (x<[1]) means that this term is equal to zero when false (x greater than Gaussian mean, parameter [1]) and has value = 1 when is true. Now in that implementation you multiply with a negative term which for some value of x < [1] you will get negative sigma.

For the skewed normal I would use the implementation as suggested in https://en.wikipedia.org/wiki/Skew_normal_distribution

TF1 * f = new TF1("f","2.*gaus(x,[0],[1],[2])*ROOT::Math::normal_cdf([3]*x,1,0)",-3,3);
f->SetParameters(1,0,1,4);
f->Draw(); 

Lorenzo

1 Like

Thank you very much!

Thank you very much for the help!

Hi, I would like to fit the derivative of a histogram (positive peak) using the skewed Gaussian. Since the distribution is not normalized, I think I should account for the amplitude for better description of the distribution. But I dont understand How to do it. Attached is the root file with the histogram and its derivative.

derivative.root (14.0 KB)

Thank you

I noticed this implementation doesn’t work for x different than zero. For some reason you cannot just change the mean (parameter [1]) to move the skewed gaussian along the x-axis. Instead, if you add another parameter for the mean it works beautifully. In the implementation below [0] is the amplitude, [1] is sigma, [2] is the skewness and [3] is the mean.

TF1 * f = new TF1("f","2.*gaus(x-[3],[0],0,[1])*ROOT::Math::normal_cdf([2]*(x-[3]),1,0)",-3,10);
f->SetParameters(1,1,4,5);
f->Draw();

Jeremias