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");
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;
224 value =
r->Poisson(prob);
void Info(const char *location, const char *msgfmt,...)
void Error(const char *location, const char *msgfmt,...)
void Warning(const char *location, const char *msgfmt,...)
class describing the range in the coordinates it supports multiple range in a coordinate.
bool IsSet() const
return true if a range has been set in any of the coordinates i.e.
unsigned int NDim() const
get range dimension
unsigned int Size(unsigned int icoord=0) const
return range size for coordinate icoord (starts from zero) Size == 0 indicates no range is present [-...
void GetRange(unsigned int irange, unsigned int icoord, double &xmin, double &xmax) const
get the i-th range for given coordinate.
DistSampler options class.
int PrintLevel() const
non-static methods for retrivieng options
static int DefaultPrintLevel()
const std::string & Algorithm() const
type of algorithm
static const std::string & DefaultAlgorithmND()
static const std::string & DefaultAlgorithm1D()
const double * Sample()
sample one event and rerturning array x with coordinates
const ROOT::Math::IMultiGenFunction & ParentPdf() const
get the parent distribution function (must be called after setting the function)
unsigned int NDim() const
return the dimension of the parent distribution (and the data)
const ROOT::Fit::DataRange & PdfRange() const
return the data range of the Pdf . Must be called after setting the function
OneDimMultiFunctionAdapter class to wrap a multidimensional function in one dimensional one.
virtual Int_t GetNdim() const
This is the base class for the ROOT Random number generators.
Ssiz_t First(char c) const
Find first occurrence of a character c.
const char * Data() const
void ToUpper()
Change string to upper case.
TUnuranContDist class describing one dimensional continuous distribution.
TUnuranDiscrDist class for one dimensional discrete distribution.
TUnuranMultiContDist class describing multi dimensional continuous distributions.
TUnuranSampler class class implementing the ROOT::Math::DistSampler interface using the UNU....
TRandom * GetRandom()
Get the random engine used by the sampler.
void SetRandom(TRandom *r)
Set the random engine to be used Needs to be called before Init to have effect.
virtual ~TUnuranSampler()
virtual destructor
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 SetPrintLevel(int level)
Set the print level (if level=-1 use default)
bool DoInitND(const char *algo)
void SetSeed(unsigned int seed)
Set the random seed for the TRandom instances used by the sampler classes Needs to be called before I...
const ROOT::Math::IGenFunction * fFunc1D
bool DoInit1D(const char *algo)
bool Init(const char *algo="")
initialize the generators with the given algorithm If no algorithm is passed used the default one for...
TUnuranSampler()
default constructor
void SetFunction(const ROOT::Math::IGenFunction &func)
set the parent function distribution to use for random sampling (one dim case)
double Sample1D()
sample one event in one dimension better implementation could be provided by the derived classes
bool DoInitDiscrete1D(const char *algo)
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...
bool Init(const std::string &distr, const std::string &method)
initialize with Unuran string interface
double Sample()
Sample 1D distribution User is responsible for having previously correctly initialized with TUnuran::...
TRandom * GetRandom()
return instance of the random engine used
void SetSeed(unsigned int seed)
set the seed for the random number generator
void SetRandom(TRandom *r)
set the random engine.
Namespace for new Math classes and functions.
double dist(Rotation3D const &r1, Rotation3D const &r2)
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
Namespace for new ROOT classes and functions.