13#ifndef ROOT_Math_DistSampler
14#define ROOT_Math_DistSampler
36 class DistSamplerOptions;
71 template<
class Function>
81 SetFunction<const ROOT::Math::IGenFunction>(func, 1);
101 virtual bool Init(
const char * =
"") {
return true;}
154 virtual void SetMode(
const std::vector<double> &) {}
195 return &
fData.front();
214 if (error) *error = 0;
223 virtual bool SampleBins(
unsigned int n,
const double * prob,
double * values,
double * errors =
nullptr) {
224 std::copy(prob,prob+
n, values);
225 if (errors) std::fill(errors,errors+
n,0);
243 virtual bool Generate(
unsigned int nevt,
double *
data,
bool eventRow =
false);
262 int nbs[1]; nbs[0] = nbins;
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Double_t(* Function)(Double_t)
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
class describing the range in the coordinates it supports multiple range in a coordinate.
Class describing the un-binned data sets (just x coordinates values) of any dimensions.
DistSampler options class.
Interface class for generic sampling of a distribution, i.e.
const double * Sample()
Sample one event and return an array x with sample coordinates values.
virtual bool Sample(double *x)=0
Sample one event in multi-dimension by filling the given array.
ROOT::Fit::DataRange * fRange
data range
virtual void DoSetFunction(const ROOT::Math::IMultiGenFunction &func, bool copy)
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)
virtual void SetFunction(const ROOT::Math::IGenFunction &func)
set the parent function distribution to use for random sampling (one dim case)
virtual ~DistSampler()
virtual destructor
virtual bool Generate(unsigned int nevt, ROOT::Fit::UnBinData &data)
Generate a un-binned data set by filling the given data set object.
virtual void SetCdf(const ROOT::Math::IGenFunction &)
Set usage of Cumulative of PDF.
const ROOT::Math::IMultiGenFunction * fFunc
internal function (ND)
DistSampler()
default constructor
void SetRange(double xmin, double xmax, int icoord=0)
Set the range in a given dimension.
const ROOT::Fit::DataRange & PdfRange() const
return the data range of the Pdf . Must be called after setting the function
virtual bool SampleBin(double prob, double &value, double *error=nullptr)
Sample one bin given an estimate of the pdf in the bin.
virtual void SetFunction(const ROOT::Math::IMultiGenFunction &func)
set the parent function distribution to use for random sampling (multi-dim case)
virtual void SetDPdf(const ROOT::Math::IGenFunction &)
Set usage of Derivative of PDF.
virtual void SetMode(const std::vector< double > &)
Set the mode of the distribution (Multi-dim case).
virtual void DoSetDimension(unsigned int ndim)
void SetFunction(Function &func, unsigned int dim)
set the parent function distribution to use for sampling (generic case)
virtual TRandom * GetRandom()
Get the random engine used by the sampler.
virtual bool Init(const char *="")
Initialize the sampling generator with the given algorithm.
virtual bool SampleBins(unsigned int n, const double *prob, double *values, double *errors=nullptr)
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.
virtual double Sample1D()
Sample one event in one dimension.
void SetRange(const std::vector< double > &xmin, const std::vector< double > &xmax)
Set the range for all dimensions (use std::vector)
virtual void SetRandom(TRandom *)
Set the random engine to be used.
std::vector< double > fData
! internal array used to cached the sample data
virtual void SetMode(double)
Set the mode of the distribution (1D case).
virtual void SetSeed(unsigned int)
Set the random seed for the TRandom instances used by the sampler classes.
bool Generate(unsigned int nevt, int nbins, double xmin, double xmax, ROOT::Fit::BinData &data, bool extend=true, bool expErr=true)
Same as before but passing the range in case of 1 dim data.
bool fOwnFunc
flag to indicate if the function is owned
bool HasParentPdf() const
Check if there is a parent distribution defined.
virtual void SetUseLogPdf(bool=true)
Use the log of the provided pdf.
Documentation for the abstract class IBaseFunctionMultiDim.
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
Template class to wrap any C++ callable object implementing operator() (const double * x) in a multi-...
This is the base class for the ROOT Random number generators.
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Namespace for new Math classes and functions.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.