20 TUnuranMultiContDist::TUnuranMultiContDist (
const ROOT::Math::IMultiGenFunction & pdf,
bool isLogPdf) :
29 TUnuranMultiContDist::TUnuranMultiContDist (TF1 * func,
unsigned int dim,
bool isLogPdf) :
36 fPdf =
new ROOT::Math::WrappedMultiTF1( *func, dim);
43 TUnuranMultiContDist::TUnuranMultiContDist(
const TUnuranMultiContDist & rhs) :
51 TUnuranMultiContDist & TUnuranMultiContDist::operator = (
const TUnuranMultiContDist &rhs)
54 if (
this == &rhs)
return *
this;
58 fIsLogPdf = rhs.fIsLogPdf;
59 fOwnFunc = rhs.fOwnFunc;
63 if (fPdf)
delete fPdf;
64 fPdf = (rhs.fPdf) ? rhs.fPdf->Clone() : 0;
69 TUnuranMultiContDist::~TUnuranMultiContDist() {
71 if (fOwnFunc && fPdf)
delete fPdf;
75 double TUnuranMultiContDist::Pdf (
const double * x)
const {
82 void TUnuranMultiContDist::Gradient(
const double * x,
double * grad)
const {
85 unsigned int ndim = NDim();
86 for (
unsigned int i = 0; i < ndim; ++i)
87 grad[i] = Derivative(x,i);
92 double TUnuranMultiContDist::Derivative(
const double * x,
int coord)
const {
102 std::vector<double> xx(NDim() );
104 xx[coord] = x[coord]+h;
double f1 = (*fPdf)(&xx.front());
105 xx[coord] = x[coord]-h;
double f2 = (*fPdf)(&xx.front());
107 xx[coord] = x[coord]+h/2;
double g1 = (*fPdf)(&xx.front());
108 xx[coord] = x[coord]-h/2;
double g2 = (*fPdf)(&xx.front());
111 double h2 = 1/(2.*h);
113 double d2 = 2*(g1 - g2);
115 double deriv = h2*(4*d2 - d0)/3.;