Roofit - finding values for peak of fit

Hi,

I have plotted a pdf fit and now want to find out what the x and y values are for the maximum.
I know you can do

Double_t fitMean = Mean.getVal(); // This gets the Mean from my plot.
x.setVal(fitMean); // This sets the x axis to the Mean value.
Double_t pdfVal = pdf.getVal(); // This gets the pdf value (normalised unfortunately)
which is between 0 and 1 (0.9 here).

But the Mean is not quite the Maximum - its slightly off.
(I think if it were the Maximum, pdf.getVal = 1 ??)

Is there some command like:

Double_t maxOfFit = pdf.getMaximum();

perhaps? or maybe

for (pdf.getVal = 1)
x = pdf.getXvalue();
y pdf.getYvalue();

Thanks for any help
Kate

Hi Kate,

This is a problem that is generally hard to solve. For specific
cases, e.g. a Gaussian it is easy if you know the analytical form.

So the solution depends a bit on your problem and how generally
you want to solve it.

A common generic approach to find a generic maximum is to sample
a large number of toy MC events from the p.d.f and take the
point with the highest value among these samples an an approximation
of the point with the maximum value. Note that for 1D problems you
should make of order 1000 samples and for 2D more like 100000 samples.

If you are interested in this generic approach I can send you some code examples.

Wouter

PS:

Double_t pdfVal = pdf.getVal(); // This gets the pdf value (normalised unfortunately)

This is incorrect: getVal() returns you the unnormalized value. Can I ask out of
curiousity why you prefer the unnormalized value of a p.d.f. over the normalized one?

Wouter,

Previously, “If you are interested in this generic approach I can send you some code examples.”

Could you post some code w/ this thread?

Thanks,
Dave