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

TUnuranContDist class describing one dimensional continuous distribution.

It is used by TUnuran to generate random numbers according to this distribution via TUnuran::Sample()

The class can be constructed from a function (TF1) representing the probability density function of the distribution. Optionally the derivative of the pdf can also be passed.

It provides a method to set the domain of the distribution ( SetDomain ) which will correspond to the range of the generated random numbers. By default the domain is (-inf, + inf), independently of the range set in the TF1 class used to construct the distribution.

In addition, some UNURAN methods requires extra information (cdf function, distribution mode, area of pdf, etc...). This information can as well be set. Some methods require instead of the pdf the log of the pdf. This can also be controlled by setting a flag when constructing this class.

Definition at line 48 of file TUnuranContDist.h.

Public Member Functions

 TUnuranContDist (const ROOT::Math::IGenFunction &pdf, const ROOT::Math::IGenFunction *dpdf=nullptr, bool isLogPdf=false, bool copyFunc=false)
 Constructor as before but from a generic function object interface for one-dim functions.
 
 TUnuranContDist (const ROOT::Math::IGenFunction *pdf, const ROOT::Math::IGenFunction *dpdf, const ROOT::Math::IGenFunction *cdf, bool isLogPdf=false, bool copyFunc=false)
 Constructor as before from pointers to generic function object interface for one-dim functions which can be use for all algorithms including those requiring only the Cdf.
 
 TUnuranContDist (const TUnuranContDist &)
 Copy constructor.
 
 TUnuranContDist (TF1 *pdf, TF1 *deriv, TF1 *cdf, bool isLogPdf=false)
 Constructor as above but with the possibility to pass also the Cdf.
 
 TUnuranContDist (TF1 *pdf=nullptr, TF1 *deriv=nullptr, bool isLogPdf=false)
 Constructor from a TF1 objects specifying the pdf and optionally from another function representing the derivative of the pdf.
 
 ~TUnuranContDist () override
 Destructor.
 
double Cdf (double x) const
 evaluate the integral (cdf) on the domain.
 
TUnuranContDistClone () const override
 Clone (required by base class)
 
double DPdf (double x) const
 evaluate the derivative of the pdf.
 
bool GetDomain (double &xmin, double &xmax) const
 check if distribution has a defined domain and return in case its domain
 
bool HasCdf () const
 check if a cdf function is provided for the distribution
 
bool HasMode () const
 check if distribution has a pre-computed mode
 
bool HasPdfArea () const
 check if distribution has a pre-computed area below the Pdf
 
TClassIsA () const override
 
bool IsLogPdf () const
 flag to control if given function represent the log of a pdf
 
double Mode () const
 return the mode (x location of maximum of the pdf)
 
TUnuranContDistoperator= (const TUnuranContDist &rhs)
 Assignment operator.
 
double Pdf (double x) const
 evaluate the Probability Density function.
 
double PdfArea () const
 return area below the pdf
 
void SetCdf (const ROOT::Math::IGenFunction &cdf)
 set cdf distribution using a generic function interface
 
void SetCdf (TF1 *cdf)
 set cdf distribution.
 
void SetDomain (double xmin, double xmax)
 Set the distribution domain.
 
void SetMode (double mode)
 set the distribution mode (x position of its maximum)
 
void SetPdfArea (double area)
 set the area below the pdf
 
void Streamer (TBuffer &) override
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 
- 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

double fArea
 area below pdf
 
const ROOT::Math::IGenFunctionfCdf
 pointer to the cdf (cumulative dist.)
 
const ROOT::Math::IGenFunctionfDPdf
 pointer to the derivative of the pdf
 
bool fHasArea
 flag to control if distribution has a pre-computed area below the pdf
 
bool fHasDomain
 flag to control if distribution has a defined domain (otherwise is [-inf,+inf]
 
bool fHasMode
 flag to control if distribution has a pre-computed mode
 
bool fIsLogPdf
 flag to control if function pointer represent log of pdf
 
double fMode
 mode of the distribution
 
bool fOwnFunc
 flag to indicate if class manages the function pointers
 
const ROOT::Math::IGenFunctionfPdf
 pointer to the pdf
 
double fXmax
 upper value of the domain
 
double fXmin
 lower value of the domain
 

#include <TUnuranContDist.h>

Inheritance diagram for TUnuranContDist:
[legend]

Constructor & Destructor Documentation

◆ TUnuranContDist() [1/5]

TUnuranContDist::TUnuranContDist ( TF1 pdf = nullptr,
TF1 deriv = nullptr,
bool  isLogPdf = false 
)
explicit

Constructor from a TF1 objects specifying the pdf and optionally from another function representing the derivative of the pdf.

The flag isLogPdf can be used to pass instead of the pdf (and its derivative) the log (and the derivative of the log) of the pdf. By default the distribution has not domain set (it is defined between [-inf,+inf], no mode, no pdf area and no cdf explicitly defined. UnuRan, if needed, can compute some of this quantities, but the user if they know them can set them in order to speed up the algorithm. For example in case of the Cdf, if the user has not set it, a numerical integration algorithm is used to estimate the Cdf from the Pdf.

Definition at line 64 of file TUnuranContDist.cxx.

◆ TUnuranContDist() [2/5]

TUnuranContDist::TUnuranContDist ( TF1 pdf,
TF1 deriv,
TF1 cdf,
bool  isLogPdf = false 
)

Constructor as above but with the possibility to pass also the Cdf.

In case an algorithm requiring only the Cdf (no Pdf), one can use this constructor passing nullptr for Pdf and derivative of the Pdf

Definition at line 46 of file TUnuranContDist.cxx.

◆ TUnuranContDist() [3/5]

TUnuranContDist::TUnuranContDist ( const ROOT::Math::IGenFunction pdf,
const ROOT::Math::IGenFunction dpdf = nullptr,
bool  isLogPdf = false,
bool  copyFunc = false 
)
explicit

Constructor as before but from a generic function object interface for one-dim functions.

Definition at line 42 of file TUnuranContDist.cxx.

◆ TUnuranContDist() [4/5]

TUnuranContDist::TUnuranContDist ( const ROOT::Math::IGenFunction pdf,
const ROOT::Math::IGenFunction dpdf,
const ROOT::Math::IGenFunction cdf,
bool  isLogPdf = false,
bool  copyFunc = false 
)

Constructor as before from pointers to generic function object interface for one-dim functions which can be use for all algorithms including those requiring only the Cdf.

Definition at line 25 of file TUnuranContDist.cxx.

◆ ~TUnuranContDist()

TUnuranContDist::~TUnuranContDist ( )
override

Destructor.

Definition at line 108 of file TUnuranContDist.cxx.

◆ TUnuranContDist() [5/5]

TUnuranContDist::TUnuranContDist ( const TUnuranContDist rhs)

Copy constructor.

Definition at line 68 of file TUnuranContDist.cxx.

Member Function Documentation

◆ Cdf()

double TUnuranContDist::Cdf ( double  x) const

evaluate the integral (cdf) on the domain.

Used by Unuran algorithm

Definition at line 158 of file TUnuranContDist.cxx.

◆ Class()

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

◆ Class_Name()

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

◆ Class_Version()

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

Definition at line 216 of file TUnuranContDist.h.

◆ Clone()

TUnuranContDist * TUnuranContDist::Clone ( ) const
inlineoverridevirtual

Clone (required by base class)

Implements TUnuranBaseDist.

Definition at line 99 of file TUnuranContDist.h.

◆ DeclFileName()

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

Definition at line 216 of file TUnuranContDist.h.

◆ DPdf()

double TUnuranContDist::DPdf ( double  x) const

evaluate the derivative of the pdf.

Used by UnuRan

Definition at line 142 of file TUnuranContDist.cxx.

◆ GetDomain()

bool TUnuranContDist::GetDomain ( double xmin,
double xmax 
) const
inline

check if distribution has a defined domain and return in case its domain

Definition at line 139 of file TUnuranContDist.h.

◆ HasCdf()

bool TUnuranContDist::HasCdf ( ) const
inline

check if a cdf function is provided for the distribution

Definition at line 148 of file TUnuranContDist.h.

◆ HasMode()

bool TUnuranContDist::HasMode ( ) const
inline

check if distribution has a pre-computed mode

Definition at line 153 of file TUnuranContDist.h.

◆ HasPdfArea()

bool TUnuranContDist::HasPdfArea ( ) const
inline

check if distribution has a pre-computed area below the Pdf

Definition at line 159 of file TUnuranContDist.h.

◆ IsA()

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

Reimplemented from TUnuranBaseDist.

Definition at line 216 of file TUnuranContDist.h.

◆ IsLogPdf()

bool TUnuranContDist::IsLogPdf ( ) const
inline

flag to control if given function represent the log of a pdf

Definition at line 175 of file TUnuranContDist.h.

◆ Mode()

double TUnuranContDist::Mode ( ) const
inline

return the mode (x location of maximum of the pdf)

Definition at line 164 of file TUnuranContDist.h.

◆ operator=()

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

Assignment operator.

Definition at line 78 of file TUnuranContDist.cxx.

◆ Pdf()

double TUnuranContDist::Pdf ( double  x) const

evaluate the Probability Density function.

Used by the UnuRan algorithms

Definition at line 137 of file TUnuranContDist.cxx.

◆ PdfArea()

double TUnuranContDist::PdfArea ( ) const
inline

return area below the pdf

Definition at line 169 of file TUnuranContDist.h.

◆ SetCdf() [1/2]

void TUnuranContDist::SetCdf ( const ROOT::Math::IGenFunction cdf)

set cdf distribution using a generic function interface

Definition at line 117 of file TUnuranContDist.cxx.

◆ SetCdf() [2/2]

void TUnuranContDist::SetCdf ( TF1 cdf)

set cdf distribution.

If a method requires it and is not set it is then estimated using numerical integration from the pdf

Definition at line 123 of file TUnuranContDist.cxx.

◆ SetDomain()

void TUnuranContDist::SetDomain ( double  xmin,
double  xmax 
)
inline

Set the distribution domain.

If min < max a domain is defined otherwise is undefined

Definition at line 117 of file TUnuranContDist.h.

◆ SetMode()

void TUnuranContDist::SetMode ( double  mode)
inline

set the distribution mode (x position of its maximum)

Definition at line 129 of file TUnuranContDist.h.

◆ SetPdfArea()

void TUnuranContDist::SetPdfArea ( double  area)
inline

set the area below the pdf

Definition at line 134 of file TUnuranContDist.h.

◆ Streamer()

void TUnuranContDist::Streamer ( TBuffer )
overridevirtual

Reimplemented from TUnuranBaseDist.

◆ StreamerNVirtual()

void TUnuranContDist::StreamerNVirtual ( TBuffer ClassDef_StreamerNVirtual_b)
inline

Definition at line 216 of file TUnuranContDist.h.

Member Data Documentation

◆ fArea

double TUnuranContDist::fArea
private

area below pdf

Definition at line 206 of file TUnuranContDist.h.

◆ fCdf

const ROOT::Math::IGenFunction* TUnuranContDist::fCdf
private

pointer to the cdf (cumulative dist.)

Definition at line 201 of file TUnuranContDist.h.

◆ fDPdf

const ROOT::Math::IGenFunction* TUnuranContDist::fDPdf
private

pointer to the derivative of the pdf

Definition at line 200 of file TUnuranContDist.h.

◆ fHasArea

bool TUnuranContDist::fHasArea
private

flag to control if distribution has a pre-computed area below the pdf

Definition at line 212 of file TUnuranContDist.h.

◆ fHasDomain

bool TUnuranContDist::fHasDomain
private

flag to control if distribution has a defined domain (otherwise is [-inf,+inf]

Definition at line 210 of file TUnuranContDist.h.

◆ fHasMode

bool TUnuranContDist::fHasMode
private

flag to control if distribution has a pre-computed mode

Definition at line 211 of file TUnuranContDist.h.

◆ fIsLogPdf

bool TUnuranContDist::fIsLogPdf
private

flag to control if function pointer represent log of pdf

Definition at line 209 of file TUnuranContDist.h.

◆ fMode

double TUnuranContDist::fMode
private

mode of the distribution

Definition at line 205 of file TUnuranContDist.h.

◆ fOwnFunc

bool TUnuranContDist::fOwnFunc
private

flag to indicate if class manages the function pointers

Definition at line 213 of file TUnuranContDist.h.

◆ fPdf

const ROOT::Math::IGenFunction* TUnuranContDist::fPdf
private

pointer to the pdf

Definition at line 199 of file TUnuranContDist.h.

◆ fXmax

double TUnuranContDist::fXmax
private

upper value of the domain

Definition at line 204 of file TUnuranContDist.h.

◆ fXmin

double TUnuranContDist::fXmin
private

lower value of the domain

Definition at line 203 of file TUnuranContDist.h.

Libraries for TUnuranContDist:

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