23 ClassImp(TUnuranContDist);
25 TUnuranContDist::TUnuranContDist (
const ROOT::Math::IGenFunction & pdf,
const ROOT::Math::IGenFunction * deriv,
bool isLogPdf,
bool copyFunc ) :
43 if (fDPdf) fDPdf->Clone();
48 TUnuranContDist::TUnuranContDist (TF1 * pdf, TF1 * deriv,
bool isLogPdf ) :
49 fPdf( (pdf) ? new ROOT::Math::WrappedTF1 ( *pdf) : 0 ),
50 fDPdf( (deriv) ? new ROOT::Math::WrappedTF1 ( *deriv) : 0 ),
67 TUnuranContDist::TUnuranContDist(
const TUnuranContDist & rhs) :
77 TUnuranContDist & TUnuranContDist::operator = (
const TUnuranContDist &rhs)
80 if (
this == &rhs)
return *
this;
85 fIsLogPdf = rhs.fIsLogPdf;
86 fHasDomain = rhs.fHasDomain;
87 fHasMode = rhs.fHasMode;
88 fHasArea = rhs.fHasArea;
89 fOwnFunc = rhs.fOwnFunc;
96 if (fPdf)
delete fPdf;
97 if (fDPdf)
delete fDPdf;
98 if (fCdf)
delete fCdf;
99 fPdf = (rhs.fPdf) ? rhs.fPdf->Clone() : 0;
100 fDPdf = (rhs.fDPdf) ? rhs.fDPdf->Clone() : 0;
101 fCdf = (rhs.fCdf) ? rhs.fCdf->Clone() : 0;
107 TUnuranContDist::~TUnuranContDist() {
110 if (fPdf)
delete fPdf;
111 if (fDPdf)
delete fDPdf;
112 if (fCdf)
delete fCdf;
116 void TUnuranContDist::SetCdf(
const ROOT::Math::IGenFunction & cdf) {
118 fCdf = (fOwnFunc) ? cdf.Clone() : &cdf;
122 void TUnuranContDist::SetCdf(TF1 * cdf) {
127 fPdf = fPdf->Clone();
128 if (fDPdf) fDPdf->Clone();
131 if (fOwnFunc && fCdf)
delete fCdf;
133 fCdf = (cdf) ?
new ROOT::Math::WrappedTF1 ( *cdf) : 0;
137 double TUnuranContDist::Pdf (
double x)
const {
144 double TUnuranContDist::DPdf(
double x)
const {
152 ROOT::Math::RichardsonDerivator rd;
153 static double gEps = 0.001;
154 double h = ( std::abs(x) > 0 ) ? gEps * std::abs(x) : gEps;
156 return rd.Derivative1( *fPdf, x, h);
159 double TUnuranContDist::Cdf(
double x)
const {
166 ROOT::Math::Integrator ig;
167 if (fXmin > fXmax)
return ig.Integral( *fPdf );
169 return ig.Integral( *fPdf, fXmin, fXmax );