Interface class for generic sampling of a distribution, i.e.
generating random numbers according to arbitrary distributions
Definition at line 57 of file DistSampler.h.
Public Member Functions | |
DistSampler () | |
default constructor | |
virtual | ~DistSampler () |
virtual destructor | |
virtual bool | Generate (unsigned int nevt, const int *nbins, ROOT::Fit::BinData &data, bool extend=true) |
generate a bin data set . | |
bool | Generate (unsigned int nevt, int nbins, double xmin, double xmax, ROOT::Fit::BinData &data, bool extend=true) |
same as before but passing the range in case of 1 dim data | |
virtual bool | Generate (unsigned int nevt, ROOT::Fit::UnBinData &data) |
generate a un-binned data sets (fill the given data set) if dataset has already data append to it | |
virtual TRandom * | GetRandom () |
Get the random engine used by the sampler To be implemented by the derived classes who needs it Returns zero by default. | |
virtual bool | Init (const char *="") |
initialize the generators with the given algorithm Implemented by derived classes who needs it (like UnuranSampler) If nothing is specified use default algorithm from DistSamplerOptions::SetDefaultAlgorithm | |
virtual bool | Init (const DistSamplerOptions &opt) |
initialize the generators with the given option which my include the algorithm but also more if the method is re-impelmented by derived class The default implementation calls the above method passing just the algorithm name | |
unsigned int | NDim () const |
return the dimension of the parent distribution (and the data) | |
const ROOT::Math::IMultiGenFunction & | ParentPdf () const |
get the parent distribution function (must be called after setting the function) | |
const double * | Sample () |
sample one event and rerturning array x with coordinates | |
virtual bool | Sample (double *x)=0 |
sample one event in multi-dimension by filling the given array return false if sampling failed | |
virtual double | Sample1D () |
sample one event in one dimension better implementation could be provided by the derived classes | |
virtual 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 its integral in the bin divided by the bin width) By default do not do random sample, just return the function values Typically Poisson statistics will be used | |
virtual bool | SampleBins (unsigned int n, const double *prob, double *values, double *errors=0) |
sample a set of bins given a vector of probabilities Typically multinomial statistics will be used and the sum of the probabilities will be equal to the total number of events to be generated For sampling the bins indipendently, SampleBin should be used | |
virtual void | SetArea (double) |
set the normalization area of distribution implemented by derived classes if needed | |
virtual void | SetFunction (const ROOT::Math::IGenFunction &func) |
set the parent function distribution to use for random sampling (one dim case) | |
virtual void | SetFunction (const ROOT::Math::IMultiGenFunction &func) |
set the parent function distribution to use for random sampling (multi-dim case) | |
template<class Function > | |
void | SetFunction (Function &func, unsigned int dim) |
set the parent function distribution to use for sampling (generic case) | |
virtual void | SetMode (double) |
set the mode of the distribution (could be useful to some methods) implemented by derived classes if needed | |
virtual void | SetRandom (TRandom *) |
Set the random engine to be used To be implemented by the derived classes who provides random sampling. | |
void | SetRange (const double *xmin, const double *xmax) |
set range for all dimensions | |
void | SetRange (const ROOT::Fit::DataRange &range) |
set range using DataRange class | |
void | SetRange (double xmin, double xmax, int icoord=0) |
set range in a given dimension | |
virtual void | SetSeed (unsigned int) |
Set the random seed for the TRandom instances used by the sampler classes To be implemented by the derived classes who provides random sampling. | |
Protected Member Functions | |
virtual void | DoSetFunction (const ROOT::Math::IMultiGenFunction &func, bool copy) |
bool | IsInitialized () |
const ROOT::Fit::DataRange & | PdfRange () const |
return the data range of the Pdf . Must be called after setting the function | |
Private Attributes | |
std::vector< double > | fData |
const ROOT::Math::IMultiGenFunction * | fFunc |
bool | fOwnFunc |
ROOT::Fit::DataRange * | fRange |
#include <Math/DistSampler.h>
|
inline |
default constructor
Definition at line 62 of file DistSampler.h.
|
virtual |
virtual destructor
Definition at line 29 of file DistSampler.cxx.
|
protectedvirtual |
Definition at line 63 of file DistSampler.cxx.
|
virtual |
generate a bin data set .
A range must have been set before (otherwise inf is returned) and the bins are equidinstant in the previously defined range bin center values must be present in given data set If the sampler is implemented by a random one, the entries will be binned according to the Poisson distribution It is assumed the distribution is normalized, otherwise the nevt must be scaled accordingly. The expected value/bin nexp = f(x_i) * binArea/ nevt Extend control if use a fixed (i.e. multinomial statistics) or floating total number of events
Definition at line 112 of file DistSampler.cxx.
|
inline |
same as before but passing the range in case of 1 dim data
Definition at line 227 of file DistSampler.h.
|
virtual |
generate a un-binned data sets (fill the given data set) if dataset has already data append to it
Definition at line 95 of file DistSampler.cxx.
|
inlinevirtual |
Get the random engine used by the sampler To be implemented by the derived classes who needs it Returns zero by default.
Reimplemented in TFoamSampler, and TUnuranSampler.
Definition at line 132 of file DistSampler.h.
|
inlinevirtual |
initialize the generators with the given algorithm Implemented by derived classes who needs it (like UnuranSampler) If nothing is specified use default algorithm from DistSamplerOptions::SetDefaultAlgorithm
Reimplemented in TFoamSampler, and TUnuranSampler.
Definition at line 101 of file DistSampler.h.
|
virtual |
initialize the generators with the given option which my include the algorithm but also more if the method is re-impelmented by derived class The default implementation calls the above method passing just the algorithm name
Reimplemented in TFoamSampler, and TUnuranSampler.
Definition at line 35 of file DistSampler.cxx.
|
protected |
Definition at line 84 of file DistSampler.cxx.
|
inline |
return the dimension of the parent distribution (and the data)
Definition at line 91 of file DistSampler.h.
|
inline |
get the parent distribution function (must be called after setting the function)
Definition at line 152 of file DistSampler.h.
|
inlineprotected |
return the data range of the Pdf . Must be called after setting the function
Definition at line 241 of file DistSampler.h.
|
inline |
sample one event and rerturning array x with coordinates
Definition at line 169 of file DistSampler.h.
sample one event in multi-dimension by filling the given array return false if sampling failed
Implemented in TFoamSampler, and TUnuranSampler.
|
inlinevirtual |
sample one event in one dimension better implementation could be provided by the derived classes
Reimplemented in TUnuranSampler.
Definition at line 161 of file DistSampler.h.
|
inlinevirtual |
sample one bin given an estimated of the pdf in the bin (this can be function value at the center or its integral in the bin divided by the bin width) By default do not do random sample, just return the function values Typically Poisson statistics will be used
Reimplemented in TFoamSampler, and TUnuranSampler.
Definition at line 187 of file DistSampler.h.
|
inlinevirtual |
sample a set of bins given a vector of probabilities Typically multinomial statistics will be used and the sum of the probabilities will be equal to the total number of events to be generated For sampling the bins indipendently, SampleBin should be used
Definition at line 198 of file DistSampler.h.
set the normalization area of distribution implemented by derived classes if needed
Reimplemented in TUnuranSampler.
Definition at line 149 of file DistSampler.h.
|
inlinevirtual |
set the parent function distribution to use for random sampling (one dim case)
Reimplemented in TFoamSampler, and TUnuranSampler.
Definition at line 80 of file DistSampler.h.
|
inlinevirtual |
set the parent function distribution to use for random sampling (multi-dim case)
Definition at line 86 of file DistSampler.h.
|
inline |
set the parent function distribution to use for sampling (generic case)
Definition at line 72 of file DistSampler.h.
set the mode of the distribution (could be useful to some methods) implemented by derived classes if needed
Reimplemented in TUnuranSampler.
Definition at line 145 of file DistSampler.h.
Set the random engine to be used To be implemented by the derived classes who provides random sampling.
Reimplemented in TFoamSampler, and TUnuranSampler.
Definition at line 118 of file DistSampler.h.
set range for all dimensions
Definition at line 48 of file DistSampler.cxx.
void ROOT::Math::DistSampler::SetRange | ( | const ROOT::Fit::DataRange & | range | ) |
set range using DataRange class
Definition at line 58 of file DistSampler.cxx.
set range in a given dimension
Definition at line 40 of file DistSampler.cxx.
Set the random seed for the TRandom instances used by the sampler classes To be implemented by the derived classes who provides random sampling.
Reimplemented in TFoamSampler, and TUnuranSampler.
Definition at line 125 of file DistSampler.h.
|
mutableprivate |
Definition at line 254 of file DistSampler.h.
|
private |
Definition at line 256 of file DistSampler.h.
|
private |
Definition at line 253 of file DistSampler.h.
|
private |
Definition at line 255 of file DistSampler.h.