Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TUnuranEmpDist Class Reference

TUnuranEmpDist class for describing empirical distributions.

It is used by TUnuran to generate double random number according to this distribution via TUnuran::Sample() or TUnuran::Sample(double *) in case of multi-dimensional empirical distributions.

An empirical distribution can be one or multi-dimension constructed from a set of unbinned data, (the class can be constructed from an iterator to a vector of data) or by using an histogram (with a pointer to the TH1 class). If the histogram contains a buffer with the original data they are used by default to estimate the empirical distribution, otherwise the bins information is used. In this binned case only one dimension is now supported.

In the case of unbinned data the density distribution is estimated by UNURAN using kernel smoothing and then random numbers are generated. In the case of bin data (which can only be one dimension) the probability density is estimated directly from the histograms and the random numbers are generated according to the histogram (like in TH1::GetRandom). This method requires some initialization time but it is faster in generating the random numbers than TH1::GetRandom and it becomes convenient to use when generating a large amount of data.

Definition at line 49 of file TUnuranEmpDist.h.

Public Member Functions

 TUnuranEmpDist (const TH1 *h1=nullptr, bool useBuffer=true)
 Constructor from a TH1 objects.
 
 TUnuranEmpDist (const TUnuranEmpDist &)
 Copy constructor.
 
template<class Iterator >
 TUnuranEmpDist (Iterator begin, Iterator end, unsigned int dim=1)
 Constructor from a set of data using an iterator to specify begin/end of the data In the case of multi-dimension the data are assumed to be passed in this order x0,y0,...x1,y1,..x2,y2,...
 
 TUnuranEmpDist (unsigned int n, double *x)
 Constructor from a set of 1D data.
 
 TUnuranEmpDist (unsigned int n, double *x, double *y)
 Constructor from a set of 2D data.
 
 TUnuranEmpDist (unsigned int n, double *x, double *y, double *z)
 Constructor from a set of 3D data.
 
 ~TUnuranEmpDist () override
 Destructor (no operations)
 
TUnuranEmpDistClone () const override
 Clone (required by base class)
 
const std::vector< double > & Data () const
 Return reference to data vector (unbinned or binned data)
 
TClassIsA () const override
 
bool IsBinned () const
 Flag to control if data are binned.
 
double LowerBin () const
 Min value of binned data (return 0 for unbinned data)
 
unsigned int NDim () const
 Number of data dimensions.
 
TUnuranEmpDistoperator= (const TUnuranEmpDist &rhs)
 Assignment operator.
 
void Streamer (TBuffer &) override
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 
double UpperBin () const
 upper value of binned data (return 0 for unbinned data)
 
- Public Member Functions inherited from TUnuranBaseDist
virtual ~TUnuranBaseDist ()
 Destructor (no operations)
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 

Static Public Member Functions

static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 
- Static Public Member Functions inherited from TUnuranBaseDist
static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 

Private Attributes

bool fBinned
 flag for binned/unbinned data
 
std::vector< doublefData
 pointer to the data vector (used for generation from un-binned data)
 
unsigned int fDim
 data dimensionality
 
double fMax
 max values (used in the binned case)
 
double fMin
 min values (used in the binned case)
 

#include <TUnuranEmpDist.h>

Inheritance diagram for TUnuranEmpDist:
[legend]

Constructor & Destructor Documentation

◆ TUnuranEmpDist() [1/6]

TUnuranEmpDist::TUnuranEmpDist ( const TH1 h1 = nullptr,
bool  useBuffer = true 
)

Constructor from a TH1 objects.

If the histogram has a buffer by default the unbinned data are used

Definition at line 21 of file TUnuranEmpDist.cxx.

◆ TUnuranEmpDist() [2/6]

template<class Iterator >
TUnuranEmpDist::TUnuranEmpDist ( Iterator  begin,
Iterator  end,
unsigned int  dim = 1 
)
inline

Constructor from a set of data using an iterator to specify begin/end of the data In the case of multi-dimension the data are assumed to be passed in this order x0,y0,...x1,y1,..x2,y2,...

Definition at line 66 of file TUnuranEmpDist.h.

◆ TUnuranEmpDist() [3/6]

TUnuranEmpDist::TUnuranEmpDist ( unsigned int  n,
double x 
)

Constructor from a set of 1D data.

Definition at line 63 of file TUnuranEmpDist.cxx.

◆ TUnuranEmpDist() [4/6]

TUnuranEmpDist::TUnuranEmpDist ( unsigned int  n,
double x,
double y 
)

Constructor from a set of 2D data.

Definition at line 72 of file TUnuranEmpDist.cxx.

◆ TUnuranEmpDist() [5/6]

TUnuranEmpDist::TUnuranEmpDist ( unsigned int  n,
double x,
double y,
double z 
)

Constructor from a set of 3D data.

Definition at line 85 of file TUnuranEmpDist.cxx.

◆ ~TUnuranEmpDist()

TUnuranEmpDist::~TUnuranEmpDist ( )
inlineoverride

Destructor (no operations)

Definition at line 91 of file TUnuranEmpDist.h.

◆ TUnuranEmpDist() [6/6]

TUnuranEmpDist::TUnuranEmpDist ( const TUnuranEmpDist rhs)

Copy constructor.

Definition at line 101 of file TUnuranEmpDist.cxx.

Member Function Documentation

◆ Class()

static TClass * TUnuranEmpDist::Class ( )
static
Returns
TClass describing this class

◆ Class_Name()

static const char * TUnuranEmpDist::Class_Name ( )
static
Returns
Name of this class

◆ Class_Version()

static constexpr Version_t TUnuranEmpDist::Class_Version ( )
inlinestaticconstexpr
Returns
Version of this class

Definition at line 147 of file TUnuranEmpDist.h.

◆ Clone()

TUnuranEmpDist * TUnuranEmpDist::Clone ( ) const
inlineoverridevirtual

Clone (required by base class)

Implements TUnuranBaseDist.

Definition at line 108 of file TUnuranEmpDist.h.

◆ Data()

const std::vector< double > & TUnuranEmpDist::Data ( ) const
inline

Return reference to data vector (unbinned or binned data)

Definition at line 114 of file TUnuranEmpDist.h.

◆ DeclFileName()

static const char * TUnuranEmpDist::DeclFileName ( )
inlinestatic
Returns
Name of the file containing the class declaration

Definition at line 147 of file TUnuranEmpDist.h.

◆ IsA()

TClass * TUnuranEmpDist::IsA ( ) const
inlineoverridevirtual
Returns
TClass describing current object

Reimplemented from TUnuranBaseDist.

Definition at line 147 of file TUnuranEmpDist.h.

◆ IsBinned()

bool TUnuranEmpDist::IsBinned ( ) const
inline

Flag to control if data are binned.

Definition at line 119 of file TUnuranEmpDist.h.

◆ LowerBin()

double TUnuranEmpDist::LowerBin ( ) const
inline

Min value of binned data (return 0 for unbinned data)

Definition at line 125 of file TUnuranEmpDist.h.

◆ NDim()

unsigned int TUnuranEmpDist::NDim ( ) const
inline

Number of data dimensions.

Definition at line 136 of file TUnuranEmpDist.h.

◆ operator=()

TUnuranEmpDist & TUnuranEmpDist::operator= ( const TUnuranEmpDist rhs)

Assignment operator.

Definition at line 108 of file TUnuranEmpDist.cxx.

◆ Streamer()

void TUnuranEmpDist::Streamer ( TBuffer )
overridevirtual

Reimplemented from TUnuranBaseDist.

◆ StreamerNVirtual()

void TUnuranEmpDist::StreamerNVirtual ( TBuffer ClassDef_StreamerNVirtual_b)
inline

Definition at line 147 of file TUnuranEmpDist.h.

◆ UpperBin()

double TUnuranEmpDist::UpperBin ( ) const
inline

upper value of binned data (return 0 for unbinned data)

Definition at line 131 of file TUnuranEmpDist.h.

Member Data Documentation

◆ fBinned

bool TUnuranEmpDist::fBinned
private

flag for binned/unbinned data

Definition at line 145 of file TUnuranEmpDist.h.

◆ fData

std::vector<double> TUnuranEmpDist::fData
private

pointer to the data vector (used for generation from un-binned data)

Definition at line 141 of file TUnuranEmpDist.h.

◆ fDim

unsigned int TUnuranEmpDist::fDim
private

data dimensionality

Definition at line 142 of file TUnuranEmpDist.h.

◆ fMax

double TUnuranEmpDist::fMax
private

max values (used in the binned case)

Definition at line 144 of file TUnuranEmpDist.h.

◆ fMin

double TUnuranEmpDist::fMin
private

min values (used in the binned case)

Definition at line 143 of file TUnuranEmpDist.h.

Libraries for TUnuranEmpDist:

The documentation for this class was generated from the following files: