Fill the histogram with mean=1 and sigma=2


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Pyroot
Compiler: Python


I need to create 10000 Gaussian Random number with mean=1 and sigma=2.

h1=ROOT.TH1F("h1","",100,-10,10)
h1.FillRandom("gaus",10000,1,2)

but it only takes two argument.

There are any another attributes which I can used to fill histogram with mean=1 and sigma=2?

import ROOT
f = ROOT.gROOT.GetFunction("gaus")
f.SetParameters(1.0, 1.0, 2.0) # Constant, Mean, Sigma
h1 = ROOT.TH1F("h1", "", 100, -10.0, 10.0)
h1.FillRandom("gaus", 10000)
h1.Draw()
{
  TF1 *f = ((TF1*)(gROOT->GetFunction("gaus")));
  f->SetParameters(1.0, 1.0, 2.0); // Constant, Mean, Sigma
  TH1F *h1 = new TH1F("h1", "", 100, -10.0, 10.0);
  h1->FillRandom("gaus", 10000);
  h1->Draw();
}
1 Like