13 #ifndef ROOT_Math_DistSampler 14 #define ROOT_Math_DistSampler 36 class DistSamplerOptions;
71 template<
class Function>
76 DoSetFunction(wf,
true);
81 SetFunction<const ROOT::Math::IGenFunction>(
func, 1);
87 DoSetFunction(func,
false);
91 unsigned int NDim()
const {
return fData.size(); }
101 virtual bool Init(
const char * =
"") {
return true;}
135 void SetRange(
double xmin,
double xmax,
int icoord = 0);
138 void SetRange(
const double * xmin,
const double * xmax);
171 return &fData.front();
178 virtual bool Sample(
double *
x) = 0;
187 virtual bool SampleBin(
double prob,
double & value,
double * error = 0) {
189 if (error) *error = 0;
198 virtual bool SampleBins(
unsigned int n,
const double * prob,
double * values,
double * errors = 0) {
199 std::copy(prob,prob+n, values);
200 if (errors)
std::fill(errors,errors+n,0);
229 int nbs[1]; nbs[0] =
nbins;
230 return Generate(nevt, nbs, data, extend);
239 bool IsInitialized() ;
virtual void SetMode(double)
set the mode of the distribution (could be useful to some methods) implemented by derived classes if ...
DistSampler()
default constructor
std::vector< double > fData
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
Namespace for new ROOT classes and functions.
const double * Sample()
sample one event and rerturning array x with coordinates
virtual void SetFunction(const ROOT::Math::IGenFunction &func)
set the parent function distribution to use for random sampling (one dim case)
Class describing the unbinned data sets (just x coordinates values) of any dimensions.
This is the base class for the ROOT Random number generators.
void SetFunction(Function &func, unsigned int dim)
set the parent function distribution to use for sampling (generic case)
Documentation for the abstract class IBaseFunctionMultiDim.
virtual void SetRandom(TRandom *)
Set the random engine to be used To be implemented by the derived classes who provides random samplin...
Double_t(* Function)(Double_t)
DistSampler options class.
ROOT::Fit::DataRange * fRange
unsigned int NDim() const
return the dimension of the parent distribution (and the data)
const ROOT::Math::IMultiGenFunction * fFunc
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
virtual double Sample1D()
sample one event in one dimension better implementation could be provided by the derived classes ...
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 an...
virtual void SetArea(double)
set the normalization area of distribution implemented by derived classes if needed ...
Interface class for generic sampling of a distribution, i.e.
class describing the range in the coordinates it supports multiple range in a coordinate.
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
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
double func(double *x, double *p)
Template class to wrap any C++ callable object implementing operator() (const double * x) in a multi-...
Namespace for new Math classes and functions.
virtual void SetSeed(unsigned int)
Set the random seed for the TRandom instances used by the sampler classes To be implemented by the de...
const ROOT::Fit::DataRange & PdfRange() const
return the data range of the Pdf . Must be called after setting the function
virtual bool Init(const char *="")
initialize the generators with the given algorithm Implemented by derived classes who needs it (like ...
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 ...
virtual void SetFunction(const ROOT::Math::IMultiGenFunction &func)
set the parent function distribution to use for random sampling (multi-dim case)
virtual TRandom * GetRandom()
Get the random engine used by the sampler To be implemented by the derived classes who needs it Retur...
const ROOT::Math::IMultiGenFunction & ParentPdf() const
get the parent distribution function (must be called after setting the function)