How can I do Kolmogorov-Smirnov test in RooFit?

Hi all

I would like to check goodness-of-fit after 1d unbinned fit using the Kolmogorov-Smirnov test.
How can I do the Kolmogorov-Smirnov test in RooFit?

Thanks in advance


The KS test is currently not interface in RooFit.

The easiest way still do it is to extract both the p.d.f.
and the dataset as a finely binned TH1, e.g.

TH1* h_func = pdf->createHistogram(“h_func”,x) ;
TH1* h_data = data->createHistogram("h_data,x) ;

and use the ROOT implementation of the KS test. The
inline documentation of both createHistogram function
shows details on how to adjust the binning if necessary.

On a separate note, I’m not sure if doing a KS test between
data and a function that was fitted to that data is fundamentally correct
as KS unlike chi^2 has no way to accomodate the information
that the function was already adjusted to the data. You might
want to check that in a statistics text book.