Get Standard deviation

Hi, I’d like to have in the box of the histograms the standard deviation value (not the RMS); I wrote:

 hene->GetStdDev();

as I read here root.cern.ch/doc/master/classTH1.html, but compiling I’ve the error:

How to resolve?
Thanks

Actually, TH1::GetRMS returns the “Standard Deviation (Sigma) of the distribution (not RMS)”.
You need ROOT 5.34/05 or newer for the TH1::GetStdDev method.

[quote=“Pepe Le Pew”]
You need ROOT 5.34/05 or newer for the TH1::GetStdDev method.[/quote]

Hi Pepe, I use 5.34.36, so what do I do? can I use the RMS value as a standard deviation or must I do other to have the standard deviation?
Thanks

It seems to me that, in line 1028 of your “mycorsplot.c”, you have something like (missing “()” in the end):
hene->GetStdDev
instead of:
hene->GetStdDev()

[quote=“Pepe Le Pew”]It seems to me that, in line 1028 of your “mycorsplot.c”, you have something like (missing “()” in the end):
hene->GetStdDev
instead of:
hene->GetStdDev()[/quote]
Hi pepe and thanks…I looked the code…but it is written:

with an appropriate version of ROOT it works fine:

$ root
  *******************************************
  *                                         *
  *        W E L C O M E  to  R O O T       *
  *                                         *
  *   Version   5.34/37      6 April 2016   *
  *                                         *
  *  You are welcome to visit our Web site  *
  *          http://root.cern.ch            *
  *                                         *
  *******************************************

root [0] cout << hpx->GetStdDev() << endl;
0.99785
root [1] 

Hi couet, I’ve root 5.34.36…

PS. I tried again…I don’t know the reason but today I don’t have error but it doesn’t write the value in the statistical box…I tried to write cout << hene->GetStdDev() << endl;, is it possible to add it in the statistical box? thanks

gStyle->SetOptStat("neMR"); // TStyle::SetOptStat

Hi pepe…I looked the link…but it wasn’t what I mean…
I’d like to have something like this

as you can see, in the statistical box there is writtene STD DEV.

ps. pepe you have a private message.

By default, ROOT 6 writes “Std Dev” while ROOT 5 writes “RMS” (but it is the “standard deviation”).

For ROOT 5, you can edit the “${ROOTSYS}/etc/system.rootrc” file (or create you own “${HOME}/.rootrc” file):

Hist.Stats.RMS:           Std Dev
Hist.Stats.RMSX:          Std Dev x
Hist.Stats.RMSY:          Std Dev y
Hist.Stats.RMSZ:          Std Dev z

Thanks pepe!

how did you get the straight line pls? graph 4

Hi! that pic is just an example that I found…I didn’t make it! However the straight line is a fit.

I write you some pieces of a macro that I used to fit a graph.

 gStyle->SetOptFit();
  TF1 *fitspettro = new TF1("fitspettro", "[0] * TMath::Power(x, -[1])", 1, 1e3);
   fitspettro->SetParameters(1.0, 2.0);
   fitspettro->SetParName(0,"c");
   fitspettro->SetParName(1,"#gamma");
 heneg->Draw();
   heneg->Fit("fitspettro");
c2->Update();
1 Like

Hello everyone,

I have a problem which is related to this topic, I hope you can assist me with.

I have a root file in which I have several histograms and I need to compute the standard deviation on a particular bin over all the histograms. Could you please tell me the steps I should follow?

Solved in How to calculate the standard deviation over a list of histograms existing in one root file? - #15 by Baktash_Amini