#ifndef ROOT_Math_TUnuranDistr
#define ROOT_Math_TUnuranDistr
#include <cassert>
#include "TF1.h"
class TUnuranDistr {
public:
TUnuranDistr() :
fFunc(0),
fCdf(0),
fDeriv(0),
fXmin(1.), fXmax(-1.),
fHasDomain(0)
{}
TUnuranDistr (const TF1 * func, const TF1 * cdf = 0, const TF1 * deriv = 0 ) :
fFunc(func),
fCdf(cdf),
fDeriv(deriv),
fXmin(1.), fXmax(-1.),
fHasDomain(0)
{
assert(func != 0);
func->GetRange(fXmin, fXmax);
}
~TUnuranDistr () {}
TUnuranDistr(const TUnuranDistr &);
TUnuranDistr & operator = (const TUnuranDistr & rhs);
inline double operator() ( double x) const {
return fFunc->Eval(x);
}
inline double Derivative( double x) const {
if (fDeriv != 0) return fDeriv->Eval(x);
return fFunc->Derivative(x);
}
inline double Cdf(double x) const {
if (fCdf != 0) return fCdf->Eval(x);
TF1 * f = const_cast<TF1*>(fFunc);
return f->Integral(fXmin, x);
}
bool GetDomain(double & xmin, double & xmax) const {
xmin = fXmin;
xmax = fXmax;
return fHasDomain;
}
void SetDomain(double xmin, double xmax) {
fXmin = xmin;
fXmax = xmax;
fHasDomain = true;
}
double Mode() const {
return fFunc->GetMaximumX(fXmin, fXmax);
}
protected:
private:
const TF1 * fFunc;
const TF1 * fCdf;
const TF1 * fDeriv;
double fXmin;
double fXmax;
bool fHasDomain;
};
#endif /* ROOT_Math_TUnuranDistr */
ROOT page - Class index - Class Hierarchy - Top of the page
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.