# Difference between RooRandom and Random

Hi guys.

I am trying to generate random numbers using a specific seed. Was toying around with the code a bit to see if I can get the same numbers if I use the same seed for RooRandom::randomGenerator->Gaus(mean, sigma) and gRandom->Gaus(mean, sigma). Just wanted to find out what the difference between the two is because I dont get the same numbers even if I do

``````RooRandom::randomGenerator->SetSeed(seed)
``````

and

``````gRandom->SetSeed(seed)
``````

Here is a sample of the code that I am using:

``````  while(1) {
xgen = gRandom->Gaus(gaus->x,gaus->sigma);
//                        xgen = gaus->x + gaus->sigma *result;
if (xgen<gaus->mean.max() && xgen>gaus->mean.min()) {
gaus->mean = xgen ;
cout << "Gaussian -> "<< xgen << endl;

break;
}
}
``````

or

``````            while(1) {
cout << "this is the seed "<< gRandom->fSeed << endl;
xgen = RooRandom::randomGenerator()->Gaus(gaus->x,gaus->sigma);
//                        xgen = gaus->x + gaus->sigma *result;
if (xgen<gaus->mean.max() && xgen>gaus->mean.min()) {
gaus->mean = xgen ;
cout << "Gaussian -> "<< xgen << endl;

break;
}
}
``````

check the code by clicking on the line number here. `RooRandom` uses `TRandom3`.
`gRandom` is probably also a TRandom3, but you have to check. Try to print it:
`gRandom->Print()`.
If they are the same, you just have to give them the same seeds. Check by printing the seeds. Note that a seed of `0` means random seed.