26 #define _USE_MATH_DEFINES // for Windows    41    double sigma_x = p[0];
    42    double sigma_y = p[1];
    44    double u = x[0] / sigma_x ;
    45    double v = x[1] / sigma_y ;
    46    double c = 1 - rho*rho ;
    48       * 
exp (-(u * u - 2 * rho * u * v + v * v ) / (2 * c));
    67    bool ret =   unr.
Init(dist,method);
    69       std::cerr << 
"Error initializing unuran with method " << unr.
MethodName() << std::endl;
    80    for (
int i = 0; i < 
n; ++i) {
    83       if (method == 
"gibbs" && i < 100)
    84          std::cout << x[0] << 
" , " << x[1] << std::endl;
    90    double prob = href->
Chi2Test(h1,
"UU");
    92    std::cout << 
"Time using Unuran  " << unr.
MethodName() << 
"   \t=\t " << time << 
"\tns/call \t\tChi2 Prob = "    93         << prob << 
"\tKS Prob = " << ksprob << std::endl;
    95       std::cout << 
"Chi2 Test failed ! " << std::endl;
   111    for (
int i = 0; i < 
n; ++i) {
   121       double prob = href->Chi2Test(h1,
"UU");
   122       std::cout << 
"Time using TF1::GetRandom()    \t=\t " << time << 
"\tns/call \t\tChi2 Prob = "<< prob << std::endl;
   124          std::cout << 
"Chi2 Test failed ! " << std::endl;
   125          href->Chi2Test(h1,
"UUP"); 
   130       std::cout << 
"Time using TF1::GetRandom()    \t=\t " << time << 
"\tns/call\n";
   151    TH2D * 
h1 = 
new TH2D(
"h1",
"UNURAN gaussian 2D distribution",100,-10,10,100,-10,10);
   152    TH2D * h2 = 
new TH2D(
"h2",
"TF1::GetRandom gaussian 2D distribution",100,-10,10,100,-10,10);
   154    TH2D * h3 = 
new TH2D(
"h3",
"UNURAN truncated gaussian 2D distribution",100,-1,1,100,-1,1);
   155    TH2D * h4 = 
new TH2D(
"h4",
"TF1::GetRandom truncated gaussian 2D distribution",100,-1,1,100,-1,1);
   159    double par[3] = {1,1,0.5};
   168    std::cout << 
" Nimber of function points in TF1, Npx = " << f->
GetNpx() << 
" Npy =  "  << f->
GetNpy() << std::endl;
   171    std::cout << 
"Test using an undefined domain :\n\n";
   189    std::string method = 
"vnrou";
   190    iret |= 
testUnuran(unr, method, dist, h1, href);
   195    iret |= 
testUnuran(unr, method, dist, h1, href);
   203    iret |= 
testUnuran(unr, method, logdist, h1, href);
   207    std::cout << 
"\nTest setting the mode in Unuran distribution:\n\n";
   212    iret |= 
testUnuran(unr, method, dist, h1, href);
   215    iret |= 
testUnuran(unr, method, dist, h1, href);
   220    iret |= 
testUnuran(unr, method, logdist, h1, href);
   229    double xmin[2] = { -1, -1 };
   230    double xmax[2] = { 1, 1 };
   232    f->
SetRange(xmin[0],xmin[1],xmax[0],xmax[1]);
   238    std::cout << 
"\nTest truncated distribution in domain [ " << xlow[0] << 
" : " << xup[0]
   239         << 
" , " << xlow[1] << 
" : " << xup[1] << 
" ] :\n\n";
   245    iret |= 
testUnuran(unr, method, dist, h3, h4);
   247    iret |= 
testUnuran(unr, method, dist, h3, h4);
   251    iret |= 
testUnuran(unr, method, logdist, h3, h4);
   255    TCanvas * 
c1 = 
new TCanvas(
"c1_unuran2D",
"Multidimensional distribution",10,10,900,900);
   258    TCanvas * c1 = 
new TCanvas(
"c1_unuran2D",
"Multidimensional distribution",10,10,500,500);
   277       std::cerr <<
"\n\nUnuRan 2D Continous Distribution Test:\t  Failed !!!!!!!\n" << std::endl;
   279       std::cerr << 
"\n\nUnuRan 2D Continous Distribution Test:\t OK\n" << std::endl;
   286 int main(
int argc, 
char **argv)
 
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1. 
 
double dist(Rotation3D const &r1, Rotation3D const &r2)
 
virtual void SetParameters(const Double_t *params)
 
virtual Int_t GetNpx() const
 
virtual void SetNpx(Int_t npx=100)
Set the number of points used to draw the function. 
 
void Start(Bool_t reset=kTRUE)
Start the stopwatch. 
 
R__EXTERN Int_t gErrorIgnoreLevel
 
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad. 
 
const double * GetLowerDomain() const
get the distribution lower domain values. 
 
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library. 
 
Double_t CpuTime()
Stop the stopwatch (if it is running) and return the cputime (in seconds) passed between the start an...
 
bool SampleMulti(double *x)
Sample multidimensional distributions User is responsible for having previously correctly initialized...
 
virtual void Reset(Option_t *option="")
Reset this histogram: contents, errors, etc. 
 
double log_gaus2d(double *x, double *p)
 
void Stop()
Stop the stopwatch. 
 
virtual Double_t Chi2Test(const TH1 *h2, Option_t *option="UU", Double_t *res=0) const
 test for comparing weighted and unweighted histograms 
 
virtual void Run(Bool_t retrn=kFALSE)
Main application eventloop. Calls system dependent eventloop via gSystem. 
 
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed. 
 
int main(int argc, char **argv)
 
int testGetRandom(TF2 *f, TH1 *h1, const TH2 *href=0)
 
Service class for 2-Dim histogram classes. 
 
R__EXTERN TSystem * gSystem
 
virtual void Draw(Option_t *option="")
Draw this histogram with options. 
 
virtual void SetNpy(Int_t npy=100)
Set the number of points used to draw the function. 
 
void SetDomain(const double *xmin, const double *xmax)
set the domain of the distribution giving an array of minimum and maximum values By default otherwise...
 
TUnuranMultiContDist class describing multi dimensional continuous distributions. ...
 
A 2-Dim function with parameters. 
 
R__EXTERN TRandom * gRandom
 
virtual void SetRange(Double_t xmin, Double_t xmax)
Initialize the upper and lower bounds to draw the function. 
 
virtual void GetRandom2(Double_t &xrandom, Double_t &yrandom)
Return 2 random numbers following this function shape. 
 
THist< 2, double, THistStatContent, THistStatUncertainty > TH2D
 
const std::string & MethodName() const
used Unuran method 
 
const double * GetUpperDomain() const
get the distribution upper domain values. 
 
virtual void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0)
Automatic pad generation by division. 
 
bool Init(const std::string &distr, const std::string &method)
initialize with Unuran string interface 
 
void SetMode(const double *x)
set the mode of the distribution (coordinates of the distribution maximum values) ...
 
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
 
double gaus2d(double *x, double *p)
 
virtual void Reset(Option_t *option="")
Reset this histogram: contents, errors, etc. 
 
Int_t Fill(Double_t)
Invalid Fill method. 
 
int testUnuran(TUnuran &unr, const std::string &method, const TUnuranMultiContDist &dist, TH2 *h1, const TH2 *href)
 
virtual Double_t KolmogorovTest(const TH1 *h2, Option_t *option="") const
Statistical test of compatibility in shape between THIS histogram and h2, using Kolmogorov test...
 
tomato 2-D histogram with a double per channel (see TH1 documentation)}