This directory contains classes for using the UNU.RAN package in ROOTUNU.RAN, (Universal Non Uniform Random number generator for generating non uniform pseudo-random numbers) is an ANSI C library licensed under GPL.
New classes have been introduced to use the UNU.RAN C library from ROOT and C++ from ROOT and using C++ objects. To use UNU.RAN one needs always an instance of the class TUnuran. It can then be used in two distinct ways:
          TUnuran unr;
          //initialize unuran to generate normal random numbers using a "arou" method
          unr.Init("normal()","method=arou");
          //......
          // sample distributions N times (generate N random numbers)
          for (int i = 0; i < N; ++i) 
                double x = unr.Sample();
           
   
  
       //1D case: create a distribution from two TF1 object pointers pdfFunc
       TUnuranContDist  dist( pdfFunc);
       //initialize unuran passing the distribution and a string defining the method
       unr.Init(dist, "method=hinv");
       // sample distribution  N times (generate N random numbers)
       for (int i = 0; i < N; ++i)
          double x = unr.Sample();
       
      
      //Multi-Dim case from a TF1 (or TF2 or TF3) object describing a multi-dimensional function
      TUnuranMultiContDist  dist( pdfFuncMulti);
      // the recommended method for multi-dimensional function is "hitro"
      unr.Init(dist, "method=hitro");  
      // sample distribution  N times (generate N random numbers)
      double x[NDIM];        
      for (int i = 0; i < N; ++i)
          unr.SampleMulti(x);
      
      // create distribution from a vector of probabilities
         double pv[NSize] = {0.1,0.2,.......};
      TUnuranDiscrDist  dist(pv, pv+NSize);	
      // the recommended method for discrete distribution is 
      unr.Init(dist, "method=dgt");
      // sample N times (generate N random numbers)       
      for (int i = 0; i < N; ++i)
         int k = unr.SampleDiscr();
  Functionality is also provided via the C++ classes for using a different random number generator by passing a TRandom pointer when constructing the TUnuran class (by default the ROOT gRandom is passed to UNURAN).
The UNU.RAN documentation provides a detailed description of all the available methods and the possible options which one can pass to UNU.RAN for the various distributions.