Mode (modal score)

Hi all.
I was just wondering if there is a one line function to get the mode (modal score) from a set of data.
I can loop on values or fill a histogram and fit it, but perhaps a function already exists. Is it the case, please?



We do not have in ROOT a specific function for this, especially in case of integer data. You should fill an histogram and then use histo.GetBinCenter( histo.GetMaximumBin() ).
In case of non-integer data you could also use the TKDE class (kernel density estimator).
After having built the class from your data vector, you can then do:

TKDE * kde = new TKDE(n, xdata); 

double mode = kde->GetFunction()->GetMaximumX();