Example of generating quasi-random numbers
Processing /mnt/build/workspace/root-makedoc-v614/rootspi/rdoc/src/v6-14-00-patches/tutorials/math/quasirandom.C...
Time for gRandom Real time 0:00:00, CP time 0.000
Time for Sobol Real time 0:00:00, CP time 0.000
Time for Niederreiter Real time 0:00:00, CP time 0.000
number of empty bins for pseudo-random = 31139
number of empty bins for sobol = 30512
number of empty bins for niederreiter-base-2 = 30512
(int) 0
#include <iostream>
int quasirandom(int n = 10000, int skip = 0) {
TH2D * h0 =
new TH2D(
"h0",
"Pseudo-random Sequence",200,0,1,200,0,1);
TH2D * h1 =
new TH2D(
"h1",
"Sobol Sequence",200,0,1,200,0,1);
TH2D * h2 =
new TH2D(
"h2",
"Niederrer Sequence",200,0,1,200,0,1);
double x[2];
for (
int i = 0; i <
n; ++i) {
}
std::cout << "Time for gRandom ";
if( skip>0) r1.Skip(skip);
for (
int i = 0; i <
n; ++i) {
r1.Next(x);
}
std::cout << "Time for Sobol ";
if( skip>0) r2.Skip(skip);
for (
int i = 0; i <
n; ++i) {
r2.Next(x);
}
std::cout << "Time for Niederreiter ";
int nzerobins0 = 0;
int nzerobins1 = 0;
int nzerobins2 = 0;
}
}
std::cout << "number of empty bins for pseudo-random = " << nzerobins0 << std::endl;
std::cout << "number of empty bins for " << r1.Name() << "\t= " << nzerobins1 << std::endl;
std::cout << "number of empty bins for " << r2.Name() << "\t= " << nzerobins2 << std::endl;
int iret = 0;
if (nzerobins1 >= nzerobins0 ) iret += 1;
if (nzerobins2 >= nzerobins0 ) iret += 2;
return iret;
}
- Author
- Lorenzo Moneta
Definition in file quasirandom.C.