Example of generating quasi-random numbers
Time for gRandom Real time 0:00:00, CP time 0.000
Time for Sobol Real time 0:00:00, CP time 0.010
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);
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) {
}
std::cout << "Time for Sobol ";
if( skip>0) r2.Skip(skip);
for (
int i = 0; i <
n; ++i) {
}
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;
}
virtual Int_t GetNbinsY() const
virtual Int_t GetNbinsX() const
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
virtual void Draw(Option_t *option="")
Draw this histogram with options.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
2-D histogram with a double per channel (see TH1 documentation)}
Int_t Fill(Double_t)
Invalid Fill method.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void Print(Option_t *option="") const
Print the real and cpu time passed between the start and stop events.
Random< ROOT::Math::GSLRngMT > RandomMT
QuasiRandom< ROOT::Math::GSLQRngNiederreiter2 > QuasiRandomNiederreiter
QuasiRandom< ROOT::Math::GSLQRngSobol > QuasiRandomSobol
- Author
- Lorenzo Moneta
Definition in file quasirandom.C.