ROOT   6.08/07 Reference Guide
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), indipendently 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 52 of file TUnuranContDist.h.

## Public Member Functions

TUnuranContDist (TF1 *pdf=0, TF1 *deriv=0, bool isLogPdf=false)
Constructor from a TF1 objects specifying the pdf and optionally from another function representing the derivative of the pdf. More...

TUnuranContDist (const ROOT::Math::IGenFunction &pdf, const ROOT::Math::IGenFunction *dpdf=0, bool isLogPdf=false, bool copyFunc=false)
Constructor as before but from a generic function object interface for one-dim functions. More...

TUnuranContDist (const TUnuranContDist &)
Copy constructor. More...

virtual ~TUnuranContDist ()
Destructor. More...

double Cdf (double x) const
evaluate the integral (cdf) on the domain. More...

virtual TUnuranContDistClone () const
Clone (required by base class) More...

double DPdf (double x) const
evaluate the derivative of the pdf. More...

bool GetDomain (double &xmin, double &xmax) const
check if distribution has a defined domain and return in case its domain More...

bool HasCdf () const
check if a cdf function is provided for the distribution More...

bool HasMode () const
check if distribution has a pre-computed mode More...

bool HasPdfArea () const
check if distribution has a pre-computed area below the Pdf More...

bool IsLogPdf () const
flag to control if given function represent the log of a pdf More...

double Mode () const
return the mode (x location of maximum of the pdf) More...

TUnuranContDistoperator= (const TUnuranContDist &rhs)
Assignment operator. More...

double Pdf (double x) const
evaluate the Probability Density function. More...

double PdfArea () const
return area below the pdf More...

void SetCdf (TF1 *cdf)
set cdf distribution. More...

void SetCdf (const ROOT::Math::IGenFunction &cdf)
set cdf distribution using a generic function interface More...

void SetDomain (double xmin, double xmax)
Set the distribution domain. More...

void SetMode (double mode)
set the distribution mode (x position of its maximum) More...

void SetPdfArea (double area)
set the area below the pdf More...

Public Member Functions inherited from TUnuranBaseDist
virtual ~TUnuranBaseDist ()
Destructor (no operations) More...

## Private Attributes

double fArea

const ROOT::Math::IGenFunctionfCdf

const ROOT::Math::IGenFunctionfDPdf

bool fHasArea

bool fHasDomain

bool fHasMode

bool fIsLogPdf

double fMode

bool fOwnFunc

const ROOT::Math::IGenFunctionfPdf

double fXmax

double fXmin

#include <TUnuranContDist.h>

Inheritance diagram for TUnuranContDist:
[legend]

## ◆ TUnuranContDist() [1/3]

 TUnuranContDist::TUnuranContDist ( TF1 * pdf = 0, TF1 * deriv = 0, 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 explicity 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. In case an algorithm requires only the Cdf (no Pdf), an empty distribution can be constructed and then the user must set afterwards the Cdf.

Definition at line 48 of file TUnuranContDist.cxx.

## ◆ TUnuranContDist() [2/3]

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

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

Definition at line 25 of file TUnuranContDist.cxx.

## ◆ ~TUnuranContDist()

 TUnuranContDist::~TUnuranContDist ( )
virtual

Destructor.

Definition at line 107 of file TUnuranContDist.cxx.

## ◆ TUnuranContDist() [3/3]

 TUnuranContDist::TUnuranContDist ( const TUnuranContDist & rhs )

Copy constructor.

Definition at line 67 of file TUnuranContDist.cxx.

## ◆ Cdf()

 double TUnuranContDist::Cdf ( double x ) const

evaluate the integral (cdf) on the domain.

Used by Unuran algorithm

Definition at line 159 of file TUnuranContDist.cxx.

## ◆ Clone()

 virtual TUnuranContDist* TUnuranContDist::Clone ( ) const
inlinevirtual

Clone (required by base class)

Implements TUnuranBaseDist.

Definition at line 95 of file TUnuranContDist.h.

## ◆ DPdf()

 double TUnuranContDist::DPdf ( double x ) const

evaluate the derivative of the pdf.

Used by UnuRan

Definition at line 144 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 135 of file TUnuranContDist.h.

## ◆ HasCdf()

 bool TUnuranContDist::HasCdf ( ) const
inline

check if a cdf function is provided for the distribution

Definition at line 144 of file TUnuranContDist.h.

## ◆ HasMode()

 bool TUnuranContDist::HasMode ( ) const
inline

check if distribution has a pre-computed mode

Definition at line 149 of file TUnuranContDist.h.

## ◆ HasPdfArea()

 bool TUnuranContDist::HasPdfArea ( ) const
inline

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

Definition at line 155 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 171 of file TUnuranContDist.h.

## ◆ Mode()

 double TUnuranContDist::Mode ( ) const
inline

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

Definition at line 160 of file TUnuranContDist.h.

## ◆ operator=()

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

Assignment operator.

Definition at line 77 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 165 of file TUnuranContDist.h.

## ◆ SetCdf() [1/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 122 of file TUnuranContDist.cxx.

## ◆ SetCdf() [2/2]

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

set cdf distribution using a generic function interface

Definition at line 116 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 113 of file TUnuranContDist.h.

## ◆ SetMode()

 void TUnuranContDist::SetMode ( double mode )
inline

set the distribution mode (x position of its maximum)

Definition at line 125 of file TUnuranContDist.h.

## ◆ SetPdfArea()

 void TUnuranContDist::SetPdfArea ( double area )
inline

set the area below the pdf

Definition at line 130 of file TUnuranContDist.h.

## ◆ fArea

 double TUnuranContDist::fArea
private

Definition at line 202 of file TUnuranContDist.h.

## ◆ fCdf

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

Definition at line 197 of file TUnuranContDist.h.

## ◆ fDPdf

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

Definition at line 196 of file TUnuranContDist.h.

## ◆ fHasArea

 bool TUnuranContDist::fHasArea
private

Definition at line 208 of file TUnuranContDist.h.

## ◆ fHasDomain

 bool TUnuranContDist::fHasDomain
private

Definition at line 206 of file TUnuranContDist.h.

## ◆ fHasMode

 bool TUnuranContDist::fHasMode
private

Definition at line 207 of file TUnuranContDist.h.

## ◆ fIsLogPdf

 bool TUnuranContDist::fIsLogPdf
private

Definition at line 205 of file TUnuranContDist.h.

## ◆ fMode

 double TUnuranContDist::fMode
private

Definition at line 201 of file TUnuranContDist.h.

## ◆ fOwnFunc

 bool TUnuranContDist::fOwnFunc
private

Definition at line 209 of file TUnuranContDist.h.

## ◆ fPdf

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

Definition at line 195 of file TUnuranContDist.h.

## ◆ fXmax

 double TUnuranContDist::fXmax
private

Definition at line 200 of file TUnuranContDist.h.

## ◆ fXmin

 double TUnuranContDist::fXmin
private

Definition at line 199 of file TUnuranContDist.h.

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