TRandom Uniform

Dear experts,

I am using TRandom to generate a random number and am using pyROOT.

R = TRandom()
rndm = R.Uniform(1)
print rndm

However, the output of the print statement is always 0.154300153255.
Am I making some obvious mistake here?

Thanks in advance,
Tanvi

This is problably because you always use the same seed. Try to do

R = TRandom(time.gmtime(0))

That fixed it. Thanks!

You probably also want to use TRandom3: https://root.cern.ch/doc/master/classTRandom.html

Note that, if you really want it random, you MUST use seed = 0 (e.g. gRandom->SetSeed(0);).

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.