TUnuranDiscrDist Class Reference

#include <TUnuranDiscrDist.h>

Inheritance diagram for TUnuranDiscrDist:

TUnuranBaseDist List of all members.

Public Member Functions

 TUnuranDiscrDist (const ROOT::Math::IGenFunction &func, bool copyFunc=false)
 TUnuranDiscrDist (TF1 *func)
template<class Iterator>
 TUnuranDiscrDist (Iterator *begin, Iterator *end)
virtual ~TUnuranDiscrDist ()
 TUnuranDiscrDist (const TUnuranDiscrDist &)
TUnuranDiscrDistoperator= (const TUnuranDiscrDist &rhs)
virtual TUnuranDiscrDistClone () const
void SetCdf (const ROOT::Math::IGenFunction &cdf)
void SetCdf (TF1 *cdf)
void SetDomain (int xmin, int xmax)
void SetMode (int mode)
void SetProbSum (double sum)
bool GetDomain (int &xmin, int &xmax) const
int Mode () const
double ProbSum () const
bool HasMode () const
bool HasProbSum () const
bool HasCdf () const
const std::vector< double > & ProbVec () const
double Pmf (int x) const
double Cdf (int x) const

Private Attributes

std::vector< doublefPVec
std::vector< doublefPVecSum
const ROOT::Math::IGenFunctionfPmf
const ROOT::Math::IGenFunctionfCdf
int fXmin
int fXmax
int fMode
double fSum
bool fHasDomain
bool fHasMode
bool fHasSum
bool fOwnFunc

Detailed Description

TUnuranDiscrDist class for one dimensional discrete distribution. It is used by TUnuran to generate integer random numbers according to this distribution via TUnuran::SampleDiscr().

The class can be constructed from a one-dimensional function (TF1 pointer) representing the discrete distribution (probability mesh function) (for example a TF1("f","TMath::PoissonI(x,[0])") ) or from a vector of probability, used by passing an iterator specifying the begin and the end of the vector. In the latter case the domain of the distribution will be defined by the vector, while in the first case is by default (0,+inf). a Method to set the domain of the distribution ( SetDomain ) is provided and it defines the range of the generated random numbers.

The derivatives of the pdf which are used by some UNURAN methods are estimated numerically in the Derivative() method. Some extra information (like distribution mode, cdf function, probability sum, etc..) can be set as well otherwise will be estimated internally if required.

Definition at line 53 of file TUnuranDiscrDist.h.


Constructor & Destructor Documentation

TUnuranDiscrDist::TUnuranDiscrDist ( const ROOT::Math::IGenFunction func,
bool  copyFunc = false 
)

Constructor from a generic function object specifying the pdf

Definition at line 23 of file TUnuranDiscrDist.cxx.

References ROOT::Math::IBaseFunctionOneDim::Clone(), fOwnFunc, and fPmf.

Referenced by Clone().

TUnuranDiscrDist::TUnuranDiscrDist ( TF1 func  ) 

Constructor from a TF1 objects specifying the pdf

Definition at line 43 of file TUnuranDiscrDist.cxx.

template<class Iterator>
TUnuranDiscrDist::TUnuranDiscrDist ( Iterator *  begin,
Iterator *  end 
) [inline]

Constructor from a vector of probability

Definition at line 71 of file TUnuranDiscrDist.h.

TUnuranDiscrDist::~TUnuranDiscrDist (  )  [virtual]

Destructor

Definition at line 96 of file TUnuranDiscrDist.cxx.

References fCdf, fOwnFunc, and fPmf.

TUnuranDiscrDist::TUnuranDiscrDist ( const TUnuranDiscrDist  ) 

Copy constructor

Definition at line 59 of file TUnuranDiscrDist.cxx.

References operator=().


Member Function Documentation

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

Assignment operator

Definition at line 68 of file TUnuranDiscrDist.cxx.

References ROOT::Math::IBaseFunctionOneDim::Clone(), fCdf, fHasDomain, fHasMode, fHasSum, fMode, fOwnFunc, fPmf, fPVec, fPVecSum, fSum, fXmax, and fXmin.

Referenced by TUnuranDiscrDist().

virtual TUnuranDiscrDist* TUnuranDiscrDist::Clone (  )  const [inline, virtual]

Clone (required by base class)

Implements TUnuranBaseDist.

Definition at line 103 of file TUnuranDiscrDist.h.

References TUnuranDiscrDist().

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

set cdf distribution from a generic function interface. If a method requires it and is not set it is estimated numerically

Definition at line 104 of file TUnuranDiscrDist.cxx.

References cdf(), fCdf, and fOwnFunc.

void TUnuranDiscrDist::SetCdf ( TF1 cdf  ) 

set cdf distribution from a TF1 pointer. If a method requires it and is not set it is estimated numerically

Definition at line 109 of file TUnuranDiscrDist.cxx.

References cdf(), ROOT::Math::IBaseFunctionOneDim::Clone(), fCdf, fOwnFunc, and fPmf.

void TUnuranDiscrDist::SetDomain ( int  xmin,
int  xmax 
) [inline]

Set the distribution domain, by default the domain is [0,INT_MAX] If xmin >= xmax a domain is removed

Definition at line 122 of file TUnuranDiscrDist.h.

References fHasDomain, fXmax, and fXmin.

void TUnuranDiscrDist::SetMode ( int  mode  )  [inline]

set the mode of the distribution (location of maximum probability)

Definition at line 135 of file TUnuranDiscrDist.h.

References fHasMode, and fMode.

Referenced by testDiscDistr(), and testPoisson().

void TUnuranDiscrDist::SetProbSum ( double  sum  )  [inline]

set the value of the sum of the probabilities in the given domain

Definition at line 140 of file TUnuranDiscrDist.h.

References fHasSum, and fSum.

Referenced by testDiscDistr(), and testPoisson().

bool TUnuranDiscrDist::GetDomain ( int &  xmin,
int &  xmax 
) const [inline]

check if distribution has domain and return in case its domain

Definition at line 145 of file TUnuranDiscrDist.h.

References fHasDomain, fXmax, and fXmin.

int TUnuranDiscrDist::Mode (  )  const [inline]

get the mode (x location of function maximum)

Definition at line 154 of file TUnuranDiscrDist.h.

References fMode.

double TUnuranDiscrDist::ProbSum (  )  const [inline]

return area of the pdf

Definition at line 159 of file TUnuranDiscrDist.h.

References fSum.

bool TUnuranDiscrDist::HasMode (  )  const [inline]

flag to control if distribution provides the mode

Definition at line 165 of file TUnuranDiscrDist.h.

References fHasMode.

bool TUnuranDiscrDist::HasProbSum (  )  const [inline]

flag to control if distribution provides the total area of the probability function

Definition at line 171 of file TUnuranDiscrDist.h.

References fHasSum.

bool TUnuranDiscrDist::HasCdf (  )  const [inline]

flag to control if distribution provides also a Cdf

Definition at line 176 of file TUnuranDiscrDist.h.

References fCdf.

const std::vector<double>& TUnuranDiscrDist::ProbVec (  )  const [inline]

retrieve a reference to the vector of the probabilities : Prob(i) If the distribution is defined from a function (i.e. for distribution with undefined domain) the vector is empty.

Definition at line 184 of file TUnuranDiscrDist.h.

References fPVec.

double TUnuranDiscrDist::Pmf ( int  x  )  const

evaluate the distribution (probability mesh function) at the integer value x. Used internally by UnuRan For integer values outside the domain the function must return 0.0

Definition at line 122 of file TUnuranDiscrDist.cxx.

References double, fPmf, and fPVec.

Referenced by Cdf().

double TUnuranDiscrDist::Cdf ( int  x  )  const

evaluate the integral (cdf) on the given domain

Definition at line 131 of file TUnuranDiscrDist.cxx.

References double, fCdf, fHasDomain, fPVecSum, fXmin, i, Pmf(), and x0.


Member Data Documentation

std::vector<double> TUnuranDiscrDist::fPVec [private]

Definition at line 204 of file TUnuranDiscrDist.h.

Referenced by operator=(), Pmf(), and ProbVec().

std::vector<double> TUnuranDiscrDist::fPVecSum [mutable, private]

Definition at line 205 of file TUnuranDiscrDist.h.

Referenced by Cdf(), and operator=().

const ROOT::Math::IGenFunction* TUnuranDiscrDist::fPmf [private]

Definition at line 206 of file TUnuranDiscrDist.h.

Referenced by operator=(), Pmf(), SetCdf(), TUnuranDiscrDist(), and ~TUnuranDiscrDist().

const ROOT::Math::IGenFunction* TUnuranDiscrDist::fCdf [private]

Definition at line 207 of file TUnuranDiscrDist.h.

Referenced by Cdf(), HasCdf(), operator=(), SetCdf(), and ~TUnuranDiscrDist().

int TUnuranDiscrDist::fXmin [private]

Definition at line 208 of file TUnuranDiscrDist.h.

Referenced by Cdf(), GetDomain(), operator=(), and SetDomain().

int TUnuranDiscrDist::fXmax [private]

Definition at line 209 of file TUnuranDiscrDist.h.

Referenced by GetDomain(), operator=(), and SetDomain().

int TUnuranDiscrDist::fMode [private]

Definition at line 210 of file TUnuranDiscrDist.h.

Referenced by Mode(), operator=(), and SetMode().

double TUnuranDiscrDist::fSum [private]

Definition at line 211 of file TUnuranDiscrDist.h.

Referenced by operator=(), ProbSum(), and SetProbSum().

bool TUnuranDiscrDist::fHasDomain [private]

Definition at line 213 of file TUnuranDiscrDist.h.

Referenced by Cdf(), GetDomain(), operator=(), and SetDomain().

bool TUnuranDiscrDist::fHasMode [private]

Definition at line 214 of file TUnuranDiscrDist.h.

Referenced by HasMode(), operator=(), and SetMode().

bool TUnuranDiscrDist::fHasSum [private]

Definition at line 215 of file TUnuranDiscrDist.h.

Referenced by HasProbSum(), operator=(), and SetProbSum().

bool TUnuranDiscrDist::fOwnFunc [private]

Definition at line 216 of file TUnuranDiscrDist.h.

Referenced by operator=(), SetCdf(), TUnuranDiscrDist(), and ~TUnuranDiscrDist().


The documentation for this class was generated from the following files:
Generated on Tue Jul 5 16:48:16 2011 for ROOT_528-00b_version by  doxygen 1.5.1