35 fHasMode(false), fHasArea(false),
52 Error(
"TUnuranSampler::Init",
"Distribution function has not been set ! Need to call SetFunction first.");
69 if (method.
First(
"D") == 0) {
70 if (
fLevel>1)
Info(
"TUnuranSampler::Init",
"Initialize one-dim discrete distribution with method %s",method.
Data());
74 if (
fLevel>1)
Info(
"TUnuranSampler::Init",
"Initialize one-dim continuous distribution with method %s",method.
Data());
79 if (
fLevel>1)
Info(
"TUnuranSampler::Init",
"Initialize multi-dim continuous distribution with method %s",method.
Data());
85 if (ret)
Info(
"TUnuranSampler::Init",
"Successfully initailized Unuran with method %s",method.
Data() );
86 else Error(
"TUnuranSampler::Init",
"Failed to initailize Unuran with method %s",method.
Data() );
115 if (range.
Size(0) > 0) {
147 if (range.
Size(0) > 0) {
151 Warning(
"DoInitDiscrete1D",
"range starts from negative values - set minimum to zero");
154 dist->
SetDomain(
int(xmin+0.1),
int(xmax+0.1));
171 std::vector<double>
xmin(range.
NDim() );
172 std::vector<double>
xmax(range.
NDim() );
188 SetFunction<TF1>(*pdf, pdf->
GetNdim());
223 if (!r)
return false;
TRandom * GetRandom()
return instance of the random engine used
virtual ~TUnuranSampler()
virtual destructor
double dist(Rotation3D const &r1, Rotation3D const &r2)
bool DoInitDiscrete1D(const char *algo)
void SetProbSum(double sum)
set the value of the sum of the probabilities in the given domain
TRandom * GetRandom()
Get the random engine used by the sampler.
Namespace for new ROOT classes and functions.
double Sample()
Sample 1D distribution User is responsible for having previously correctly initialized with TUnuran::...
const std::string & Algorithm() const
type of algorithm
bool DoInit1D(const char *algo)
const double * Sample()
sample one event and rerturning array x with coordinates
void SetMode(int mode)
set the mode of the distribution (location of maximum probability)
void ToUpper()
Change string to upper case.
bool Init(const char *algo="")
initialize the generators with the given algorithm If no algorithm is passed used the default one for...
int SampleDiscr()
Sample discrete distributions User is responsible for having previously correctly initialized with TU...
bool SampleMulti(double *x)
Sample multidimensional distributions User is responsible for having previously correctly initialized...
void SetPrintLevel(int level)
Set the print level (if level=-1 use default)
TUnuranSampler()
default constructor
double Sample1D()
sample one event in one dimension better implementation could be provided by the derived classes ...
void SetFunction(const ROOT::Math::IGenFunction &func)
set the parent function distribution to use for random sampling (one dim case)
void GetRange(unsigned int irange, unsigned int icoord, double &xmin, double &xmax) const
get the i-th range for given coordinate.
OneDimMultiFunctionAdapter class to wrap a multidimensional function in one dimensional one...
This is the base class for the ROOT Random number generators.
void SetSeed(unsigned int seed)
set the seed for the random number generator
void Info(const char *location, const char *msgfmt,...)
void SetDomain(int xmin, int xmax)
Set the distribution domain, by default the domain is [0,INT_MAX] If xmin >= xmax a domain is removed...
TUnuranDiscrDist class for one dimensional discrete distribution.
Ssiz_t First(char c) const
Find first occurrence of a character c.
virtual Int_t GetNdim() const
void Error(const char *location, const char *msgfmt,...)
int PrintLevel() const
non-static methods for retrivieng options
static const std::string & DefaultAlgorithmND()
DistSampler options class.
unsigned int Size(unsigned int icoord=0) const
return range size for coordinate icoord (starts from zero) Size == 0 indicates no range is present [-...
unsigned int NDim() const
return the dimension of the parent distribution (and the data)
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. ...
void SetSeed(unsigned int seed)
Set the random seed for the TRandom instances used by the sampler classes Needs to be called before I...
bool SampleBin(double prob, double &value, double *error=0)
sample one bin given an estimated of the pdf in the bin (this can be function value at the center or ...
void Warning(const char *location, const char *msgfmt,...)
static int DefaultPrintLevel()
void SetDomain(double xmin, double xmax)
Set the distribution domain.
class describing the range in the coordinates it supports multiple range in a coordinate.
bool DoInitND(const char *algo)
void SetPdfArea(double area)
set the area below the pdf
Namespace for new Math classes and functions.
const ROOT::Fit::DataRange & PdfRange() const
return the data range of the Pdf . Must be called after setting the function
TUnuranContDist class describing one dimensional continuous distribution.
unsigned int NDim() const
get range dimension
bool Init(const std::string &distr, const std::string &method)
initialize with Unuran string interface
void SetRandom(TRandom *r)
Set the random engine to be used Needs to be called before Init to have effect.
TUnuranSampler class class implementing the ROOT::Math::DistSampler interface using the UNU...
bool IsSet() const
return true if a range has been set in any of the coordinates i.e.
static const std::string & DefaultAlgorithm1D()
virtual Int_t Poisson(Double_t mean)
Generates a random integer N according to a Poisson law.
const ROOT::Math::IMultiGenFunction & ParentPdf() const
get the parent distribution function (must be called after setting the function)
void SetMode(double mode)
set the distribution mode (x position of its maximum)
void SetRandom(TRandom *r)
set the random engine.
const ROOT::Math::IGenFunction * fFunc1D
const char * Data() const