TUnuran class.
Interface to the UNU.RAN package for generating non uniform random numbers. This class wraps the UNU.RAN calls in C++ methods. It provides methods for initializing Unuran and then to sample the desired distribution. It provides support for initializing UNU.RAN in these following way (various signatures for TUnuran::Init)
- with string API via TUnuran::Init passing the distribution type and the method
- using a one-dimensional distribution object defined by TUnuranContDist
- using a multi-dimensional distribution object defined by TUnuranMultiContDist
- using a discrete one-dimensional distribution object defined by TUnuranDiscrDist
- using an empirical distribution defined by TUnuranEmpDist
- using pre-defined distributions. Presently only support for Poisson (TUnuran::InitPoisson) and Binomial (TUnuran::InitBinomial) are provided. Other distributions can however be generated using the previous methods (in particular via the string API)
The sampling is provided via these methods:
- TUnuran::Sample() returns a double for all one-dimensional distribution
- TUnuran::SampleDiscr() returns an integer for one-dimensional discrete distribution
- TUnuran::Sample(double *) sample a multi-dimensional distribution. A pointer to a vector with size at least equal to the distribution dimension must be passed
In addition is possible to set the random number generator in the constructor of the class, its seed via the TUnuran::SetSeed() method.
Definition at line 79 of file TUnuran.h.
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.