Arnab7
1
Hi,
I want to fill a histogram with a Gaussian distribution with known mean value (most likely x$_c$ is 0) and sigma.
How can do that?
Secondly, I want to use the values of y for various x values.
Is it possible access that also for further calculation.
Regards,
A
Hi Arnab,
one way to do it:
TH1D h("h", "h", /*nbins=*/100, /*xmin=*/-3, /*xmax=*/3);
h.FillRandom("gaus", /*nsamples=*/5000);
You can access the bin content of a histogram with h.GetBinContent(nbin)
.
Hope this helps,
Enrico
Arnab7
3
Hi Enrico,
Thanks for your kind help.
One more thing is I was trying something like:
TRandom3 rndgen;
h.Fill(rndgen.Gaus(0.0,10));
But I don't get any Gaussian distribution, instead, I get a line.
Do you have any idea to fix it?
Thanks,
A
Hi,
from just that snippet I can’t be sure exactly what you are doing wrong, but this works:
TH1D h("h", "h", 100, -3., 3.);
TRandom3 rndgen;
for (int i = 0; i < 100; ++i) h.Fill(rndgen.Gaus(0.,1.));
h2.Draw();
Arnab7
5
Hi,
Now it works.
Thank you very much.
system
Closed
6
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.