TUnuran Class Reference

#include <TUnuran.h>

List of all members.

Public Member Functions

 TUnuran (TRandom *r=0, unsigned int log=0)
 ~TUnuran ()
bool Init (const std::string &distr, const std::string &method)
bool Init (const TUnuranContDist &distr, const std::string &method="auto")
bool Init (const TUnuranMultiContDist &distr, const std::string &method="hitro")
bool Init (const TUnuranDiscrDist &distr, const std::string &method="auto")
bool Init (const TUnuranEmpDist &distr, const std::string &method="empk")
bool InitPoisson (double mu, const std::string &method="dstd")
bool InitBinomial (unsigned int ntot, double prob, const std::string &method="dstd")
bool ReInitDiscrDist (unsigned int npar, double *params)
double Sample ()
bool SampleMulti (double *x)
int SampleDiscr ()
void SetRandom (TRandom *r)
TRandomGetRandom ()
void SetSeed (unsigned int seed)
bool SetLogLevel (unsigned int iflag=1)
bool SetLogStream ()
const std::stringMethodName () const

Protected Member Functions

bool SetRandomGenerator ()
bool SetContDistribution (const TUnuranContDist &dist)
bool SetMultiDistribution (const TUnuranMultiContDist &dist)
bool SetDiscreteDistribution (const TUnuranDiscrDist &dist)
bool SetEmpiricalDistribution (const TUnuranEmpDist &dist)
bool SetMethodAndInit ()

Protected Attributes

UNUR_GENfGen
UNUR_DISTRfUdistr
UNUR_URNGfUrng
std::auto_ptr< TUnuranBaseDistfDist
TRandomfRng
std::string fMethod

Private Member Functions

 TUnuran (const TUnuran &)
TUnuranoperator= (const TUnuran &rhs)


Detailed Description

Definition at line 77 of file TUnuran.h.


Constructor & Destructor Documentation

TUnuran::TUnuran ( TRandom r = 0,
unsigned int  log = 0 
)

Constructor with a generator instance and given level of log output

Definition at line 36 of file TUnuran.cxx.

References fRng, and gRandom.

TUnuran::~TUnuran (  ) 

Destructor

Definition at line 57 of file TUnuran.cxx.

References fGen, fUdistr, and fUrng.

TUnuran::TUnuran ( const TUnuran  )  [private]

Copy constructor

Definition at line 67 of file TUnuran.cxx.


Member Function Documentation

TUnuran & TUnuran::operator= ( const TUnuran rhs  )  [private]

Assignment operator

Definition at line 72 of file TUnuran.cxx.

bool TUnuran::Init ( const std::string distr,
const std::string method 
)

initialize with Unuran string interface

Definition at line 79 of file TUnuran.cxx.

References Error, fGen, s, and SetRandomGenerator().

Referenced by TUnuranSampler::DoInit1D(), TUnuranSampler::DoInitDiscrete1D(), TUnuranSampler::DoInitND(), UnuRanDist::Gaus(), run_unuran(), testAll(), testBinomial(), testDiscDistr(), testDistr1D(), testDistrMultiDim(), testEmpDistr(), testPoisson(), testProbVector(), testStringAPI(), testUnBinnedFit(), testUnuran(), unuranDistr(), unuranGraf(), unuranGraf2D(), unuranHist(), and unuranSimple().

bool TUnuran::Init ( const TUnuranContDist distr,
const std::string method = "auto" 
)

Initialize method for continuous one-dimensional distribution. User must provide a distribution object (which is copied inside) and a string for a method. For the list of available method for 1D cont. distribution see the UnuRan doc. A re-initialization is needed whenever distribution parameters have been changed.

Definition at line 93 of file TUnuran.cxx.

References distr(), fDist, fMethod, SetContDistribution(), SetMethodAndInit(), and SetRandomGenerator().

bool TUnuran::Init ( const TUnuranMultiContDist distr,
const std::string method = "hitro" 
)

Initialize method for continuous multi-dimensional distribution. User must provide a distribution object (which is copied inside) and a string for a method. For the list of available method for multivariate cont. distribution see the UnuRan doc A re-initialization is needed whenever distribution parameters have been changed.

Definition at line 109 of file TUnuran.cxx.

References distr(), fDist, fMethod, SetMethodAndInit(), SetMultiDistribution(), and SetRandomGenerator().

bool TUnuran::Init ( const TUnuranDiscrDist distr,
const std::string method = "auto" 
)

Initialize method for continuous one-dimensional discrete distribution. User must provide a distribution object (which is copied inside) and a string for a method. For the list of available method for 1D discrete distribution see the UnuRan doc A re-initialization is needed whenever distribution parameters have been changed.

Definition at line 125 of file TUnuran.cxx.

References distr(), fDist, fMethod, SetDiscreteDistribution(), SetMethodAndInit(), and SetRandomGenerator().

bool TUnuran::Init ( const TUnuranEmpDist distr,
const std::string method = "empk" 
)

Initialize method for continuous empirical distribution. User must provide a distribution object (which is copied inside) and a string for a method. The distribution object can represent binned (only 1D) or unbinned (1D or multi-dim) data The method for the unbinned empirical distribution are based on the kernel smoothing, see UnuRan doc A re-initialization is needed whenever distribution parameters have been changed.

Definition at line 139 of file TUnuran.cxx.

References distr(), fDist, fMethod, SetEmpiricalDistribution(), SetMethodAndInit(), and SetRandomGenerator().

bool TUnuran::InitPoisson ( double  mu,
const std::string method = "dstd" 
)

Initialize method for the Poisson distribution Used to generate poisson numbers for a constant parameter mu of the Poisson distribution. Use after the method TUnuran::SampleDiscr to generate the numbers. The flag reinit perform a fast re-initialization when only the distribution parameters are changed in the subsequent calls. If the same TUnuran object is used to generate with other distributions it cannot be used.

Definition at line 423 of file TUnuran.cxx.

References fMethod, fUdistr, p, SetMethodAndInit(), and SetRandomGenerator().

Referenced by UnuRanDist::Poisson(), testAll(), and testPoisson().

bool TUnuran::InitBinomial ( unsigned int  ntot,
double  prob,
const std::string method = "dstd" 
)

Initialize method for the Binomial distribution Used to generate poisson numbers for a constant parameters (n,p) of the Binomial distribution. Use after the method TUnuran::SampleDiscr to generate the numbers. The flag reinit perform a fast re-initialization when only the distribution parameters are changed in the subsequent calls. If the same TUnuran object is used to generate with other distributions it cannot be used.

Definition at line 438 of file TUnuran.cxx.

References fMethod, fUdistr, par, SetMethodAndInit(), and SetRandomGenerator().

Referenced by UnuRanDist::Binomial(), testAll(), and testBinomial().

bool TUnuran::ReInitDiscrDist ( unsigned int  npar,
double params 
)

Reinitialize UNURAN by changing the distribution parameters but mantaining same distribution and method It is implemented now only for predefined discrete distributions like the poisson or the binomial

Definition at line 453 of file TUnuran.cxx.

References fGen, fUdistr, and Warning().

Referenced by UnuRanDist::Binomial(), UnuRanDist::Poisson(), testBinomial(), and testPoisson().

double TUnuran::Sample (  ) 

Sample 1D distribution User is responsible for having previously correctly initialized with TUnuran::Init

Definition at line 389 of file TUnuran.cxx.

References fGen.

Referenced by UnuRanDist::Gaus(), TUnuranSampler::Sample1D(), testAll(), testDistr1D(), testEmpDistr(), testStringAPI(), DistTest::testUnuran(), unuranDistr(), unuranHist(), and unuranSimple().

bool TUnuran::SampleMulti ( double x  ) 

Sample multidimensional distributions User is responsible for having previously correctly initialized with TUnuran::Init

Definition at line 396 of file TUnuran.cxx.

References fGen.

Referenced by run_unuran(), TUnuranSampler::Sample(), testDistrMultiDim(), testUnBinnedFit(), testUnuran(), unuranGraf(), and unuranGraf2D().

int TUnuran::SampleDiscr (  ) 

Sample discrete distributions User is responsible for having previously correctly initialized with TUnuran::Init

Definition at line 382 of file TUnuran.cxx.

References fGen.

Referenced by UnuRanDist::Binomial(), UnuRanDist::Poisson(), TUnuranSampler::Sample1D(), testAll(), testBinomial(), testDiscDistr(), testPoisson(), and testUnuran().

void TUnuran::SetRandom ( TRandom r  )  [inline]

set the random engine. Must be called before init to have effect

Definition at line 205 of file TUnuran.h.

References fRng.

Referenced by TUnuranSampler::SetRandom().

TRandom* TUnuran::GetRandom (  )  [inline]

return instance of the random engine used

Definition at line 212 of file TUnuran.h.

References fRng.

Referenced by TUnuranSampler::GetRandom(), and TUnuranSampler::SampleBin().

void TUnuran::SetSeed ( unsigned int  seed  ) 

set the seed for the random number generator

Definition at line 404 of file TUnuran.cxx.

References fRng, and TRandom::SetSeed().

Referenced by TUnuranSampler::SetSeed().

bool TUnuran::SetLogLevel ( unsigned int  iflag = 1  ) 

set log level

Definition at line 408 of file TUnuran.cxx.

References fGen.

bool TUnuran::SetLogStream (  )  [inline]

set stream for log and error (not yet implemented)

Definition at line 230 of file TUnuran.h.

const std::string& TUnuran::MethodName (  )  const [inline]

used Unuran method

Definition at line 235 of file TUnuran.h.

References fMethod.

Referenced by run_unuran(), testBinomial(), testDiscDistr(), testDistr1D(), testDistrMultiDim(), testEmpDistr(), testPoisson(), testStringAPI(), testUnuran(), DistTest::testUnuran(), unuranDistr(), unuranGraf(), unuranGraf2D(), and unuranHist().

bool TUnuran::SetRandomGenerator (  )  [protected]

Definition at line 156 of file TUnuran.cxx.

References fGen, fRng, and fUrng.

Referenced by Init(), InitBinomial(), and InitPoisson().

bool TUnuran::SetContDistribution ( const TUnuranContDist dist  )  [protected]

Definition at line 173 of file TUnuran.cxx.

References ContDist::Cdf(), ROOT::Math::gv_detail::dist(), ContDist::Dpdf(), Error, fUdistr, ContDist::Pdf(), xmax, and xmin.

Referenced by Init().

bool TUnuran::SetMultiDistribution ( const TUnuranMultiContDist dist  )  [protected]

Definition at line 219 of file TUnuran.cxx.

References ROOT::Math::gv_detail::dist(), MultiDist::Dpdf(), Error, fUdistr, MultiDist::Pdf(), MultiDist::Pdpdf(), xmax, and xmin.

Referenced by Init().

bool TUnuran::SetDiscreteDistribution ( const TUnuranDiscrDist dist  )  [protected]

Definition at line 304 of file TUnuran.cxx.

References DiscrDist::Cdf(), ROOT::Math::gv_detail::dist(), Error, fUdistr, DiscrDist::Pmf(), xmax, and xmin.

Referenced by Init().

bool TUnuran::SetEmpiricalDistribution ( const TUnuranEmpDist dist  )  [protected]

Definition at line 263 of file TUnuran.cxx.

References ROOT::Math::gv_detail::dist(), Error, fUdistr, max, min, n, and nbins.

Referenced by Init().

bool TUnuran::SetMethodAndInit (  )  [protected]

change the method and initialize Unuran with the previously given distribution

Definition at line 351 of file TUnuran.cxx.

References Error, fGen, fMethod, fUdistr, NULL, and par.

Referenced by Init(), InitBinomial(), and InitPoisson().


Member Data Documentation

UNUR_GEN* TUnuran::fGen [protected]

Definition at line 259 of file TUnuran.h.

Referenced by Init(), ReInitDiscrDist(), Sample(), SampleDiscr(), SampleMulti(), SetLogLevel(), SetMethodAndInit(), SetRandomGenerator(), and ~TUnuran().

UNUR_DISTR* TUnuran::fUdistr [protected]

Definition at line 260 of file TUnuran.h.

Referenced by InitBinomial(), InitPoisson(), ReInitDiscrDist(), SetContDistribution(), SetDiscreteDistribution(), SetEmpiricalDistribution(), SetMethodAndInit(), SetMultiDistribution(), and ~TUnuran().

UNUR_URNG* TUnuran::fUrng [protected]

Definition at line 261 of file TUnuran.h.

Referenced by SetRandomGenerator(), and ~TUnuran().

std::auto_ptr<TUnuranBaseDist> TUnuran::fDist [protected]

Definition at line 262 of file TUnuran.h.

Referenced by Init().

TRandom* TUnuran::fRng [protected]

Definition at line 263 of file TUnuran.h.

Referenced by GetRandom(), SetRandom(), SetRandomGenerator(), SetSeed(), and TUnuran().

std::string TUnuran::fMethod [protected]

Definition at line 264 of file TUnuran.h.

Referenced by Init(), InitBinomial(), InitPoisson(), MethodName(), and SetMethodAndInit().


The documentation for this class was generated from the following files:
Generated on Tue Jul 5 16:48:16 2011 for ROOT_528-00b_version by  doxygen 1.5.1