What is the range of numbers generated by G4UniformRand()?


I’m using the code snippet below from B1PrimaryGeneratorAction in my simulations and I would like to know what is the range of values generated by G4UniformRand(). I couldn’t find this information anywhere. Thanks for your response in advance!

G4double size = 0.8; 
G4double x0 = envSizeXY * (G4UniformRand()-0.5);
G4double y0 = envSizeXY * (G4UniformRand()-0.5);
G4double z0 = -0.5 * envSizeZ;

@weller @allison @willmatava @mkelsey

You’re right, it’s not written down in the documentation. From $G4INCLUDE/Randomize.hh,

#define G4UniformRand() CLHEP::HepRandom::getTheEngine()->flat()

and then from $G4INCLUDE/CLHEP/Random/RandFlat.h,

// Default boundaries ]0.1[ for operator()().
1 Like

Thank you for the response.