Fastest way to obtain mean and variance of a small dataset?

Hi Rooters,

Every once in a while I have about 10 values of which I need to calculate mean and variance. Which is the fastest way to do so in Root? I’m asking for a quick’n’dirty solution!


  • Moritz

see TMath::Mean, RMS, etc


Ok great!

Just to see if I understand the code correctly: The standard deviation of the mean (TMath::Mean(…)) is obtained by TMath::RMS(…)/sqrt(n-1), and the variance of the dataset is TMath::RMS(…)*sqrt(n/(n-1)), right?

Why don’t we have TMath::StdDev(…) and TMath::Variance(…)?


  • Moritz