class TUnuranDiscrDist: public TUnuranBaseDist


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.



Function Members (Methods)

public:
TUnuranDiscrDist(TF1* func = 0)
TUnuranDiscrDist(const TUnuranDiscrDist&)
TUnuranDiscrDist(double* begin, double* end)
virtual~TUnuranDiscrDist()
doubleCdf(int x) const
static TClass*Class()
virtual TUnuranDiscrDist*Clone() const
boolGetDomain(int& xmin, int& xmax) const
boolHasCdf() const
boolHasMode() const
boolHasProbSum() const
virtual TClass*IsA() const
intMode() const
TUnuranDiscrDist&operator=(const TUnuranDiscrDist& rhs)
doublePmf(int x) const
doubleProbSum() const
const vector<double>&ProbVec() const
voidSetCdf(TF1* cdf)
voidSetDomain(int xmin, int xmax)
voidSetMode(int mode)
voidSetProbSum(double sum)
virtual voidShowMembers(TMemberInspector& insp, char* parent)
virtual voidStreamer(TBuffer& b)
voidStreamerNVirtual(TBuffer& b)

Data Members

private:
TF1*fCdfpointer to the cumulative distribution function
boolfHasDomainflag to control if distribution has a defined domain (otherwise is [0,INT_MAX])
boolfHasModeflag to control if distribution has a pre-computed mode
boolfHasSumflag to control if distribution has a pre-computed sum of the probabilities
intfModemode of the distribution
vector<double>fPVecVector of the probabilities
TF1*fPmfpointer to a function calculating the probability
doublefSumtotal sum of the probabilities in the given domain
doublefX[1]! cached vector for using TF1::EvalPar
intfXmaxupper value of the domain
intfXminlower value of the domain

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

TUnuranDiscrDist(TF1 * func = 0)
Constructor from a TF1 objects specifying the pdf

TUnuranDiscrDist(double* begin, double* end)
Constructor from a vector of probability

{}
~TUnuranDiscrDist()
Destructor (no operations)

{}
TUnuranDiscrDist(const TUnuranDiscrDist &)
Copy constructor

TUnuranDiscrDist * Clone()
Clone (required by base class)

{ return new TUnuranDiscrDist(*this); }
void SetCdf(TF1* cdf)
set cdf distribution. If a method requires it
and is not set it is estimated numerically

{ fCdf = cdf; }
void SetDomain(int xmin, int xmax)
Set the distribution domain, by default the domain is [0,INT_MAX]
If xmin >= xmax a domain is removed

void SetMode(int mode)
set the mode of the distribution (location of maximum probability)

{ fMode = mode; fHasMode=true;}
void SetProbSum(double sum)
set the value of the sum of the probabilities in the given domain

{ fSum = sum; fHasSum=true; }
bool GetDomain(int& xmin, int& xmax) const
check if distribution has domain and return in case its domain

int Mode()
get the mode   (x location of function maximum)

{ return fMode; }
double ProbSum()
return area of the pdf

{ return fSum; }
bool HasMode()
flag to control if distribution provides the mode

{ return fHasMode; }
bool HasProbSum()
flag to control if distribution provides the total area of the probability function

{ return fHasSum; }
bool HasCdf()
flag to control if distribution provides also a Cdf

{ return fCdf != 0; }
const std::vector<double> & ProbVec()
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.

{ return fPVec; }
double 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

double Cdf(int x) const
evaluate the integral (cdf)  on the given domain


Last update: root/unuran:$Id: TUnuranDiscrDist.h 21526 2007-12-20 10:42:41Z moneta $
Copyright (c) 2006 LCG ROOT Math Team, CERN/PH-SFT *

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.