42 #define USE_PARAMCACHE
58 template <
class ParamFunc = ROOT::Math::IParamMultiFunction>
59 class IntegralEvaluator {
63 IntegralEvaluator(
const ParamFunc &
func,
const double * p,
bool useIntegral =
true) :
77 void SetFunction(
const ParamFunc & func,
const double * p = 0) {
92 fIg1Dim->SetFunction( static_cast<const ROOT::Math::IGenFunction &>(*fFunc1Dim) );
97 fIgNDim->SetFunction(*fFuncNDim);
108 ~IntegralEvaluator() {
109 if (fIg1Dim)
delete fIg1Dim;
110 if (fIgNDim)
delete fIgNDim;
111 if (fFunc1Dim)
delete fFunc1Dim;
112 if (fFuncNDim)
delete fFuncNDim;
117 double F1 (
double x)
const {
118 double xx[1]; xx[0] =
x;
119 return (*fFunc)( xx, fParams);
122 double FN(
const double * x)
const {
123 return (*fFunc)(
x, fParams);
126 double Integral(
const double *
x1,
const double *
x2) {
128 return (fIg1Dim) ? fIg1Dim->Integral( *x1, *x2) : fIgNDim->Integral( x1, x2);
130 double operator()(
const double *x1,
const double * x2) {
133 double dV = *x2 - *
x1;
134 return fIg1Dim->Integral( *x1, *x2)/dV;
138 for (
unsigned int i = 0; i < fDim; ++i)
139 dV *= ( x2[i] - x1[i] );
140 return fIgNDim->Integral( x1, x2)/dV;
152 IntegralEvaluator(
const IntegralEvaluator& rhs);
153 IntegralEvaluator&
operator=(
const IntegralEvaluator& rhs);
156 const double * fParams;
158 const ParamFunc * fFunc;
167 template<
class GradFunc = IGradModelFunction>
168 struct ParamDerivFunc {
169 ParamDerivFunc(
const GradFunc &
f) : fFunc(f), fIpar(0) {}
170 void SetDerivComponent(
unsigned int ipar) { fIpar = ipar; }
171 double operator() (
const double *
x,
const double *p)
const {
172 return fFunc.ParameterDerivative( x, p, fIpar );
174 unsigned int NDim()
const {
return fFunc.NDim(); }
175 const GradFunc & fFunc;
181 class SimpleGradientCalculator {
191 SimpleGradientCalculator(
int gdim,
const IModelFunction &
func,
double eps = 2.
E-8,
int istrat = 1) :
197 fVec(std::vector<double>(gdim) )
202 double DoParameterDerivative(
const double *
x,
const double *p,
double f0,
int k)
const {
209 double f1 = fFunc(x, &fVec.front() );
212 double f2 = fFunc(x, &fVec.front() );
213 deriv = 0.5 * ( f2 -
f1 )/h;
216 deriv = ( f1 - f0 )/h;
222 unsigned int NDim()
const {
226 unsigned int NPar()
const {
230 double ParameterDerivative(
const double *x,
const double *p,
int ipar)
const {
232 std::copy(p, p+fN, fVec.begin());
233 double f0 = fFunc(x, p);
234 return DoParameterDerivative(x,p,f0,ipar);
238 void ParameterGradient(
const double * x,
const double * p,
double f0,
double *
g) {
240 std::copy(p, p+fN, fVec.begin());
241 for (
unsigned int k = 0; k < fN; ++k) {
242 g[k] = DoParameterDerivative(x,p,f0,k);
247 void Gradient(
const double * x,
const double * p,
double f0,
double * g) {
249 std::copy(x, x+fN, fVec.begin());
250 for (
unsigned int k = 0; k < fN; ++k) {
256 double f1 = fFunc( &fVec.front(), p );
259 double f2 = fFunc( &fVec.front(), p );
260 g[k] = 0.5 * ( f2 -
f1 )/h;
263 g[k] = ( f1 - f0 )/h;
276 mutable std::vector<double> fVec;
311 template <
class GFunc>
313 const double *
x1,
const double *
x2,
const double * p,
double *
g) {
316 ParamDerivFunc<GFunc> pfunc( gfunc);
317 IntegralEvaluator<ParamDerivFunc<GFunc> > igDerEval( pfunc, p,
true);
319 unsigned int npar = gfunc.NPar();
320 for (
unsigned int k = 0; k < npar; ++k ) {
321 pfunc.SetDerivComponent(k);
322 g[k] = igDerEval( x1, x2 );
342 unsigned int n = data.
Size();
347 #ifdef USE_PARAMCACHE
361 std::cout <<
"\n\nFit data size = " << n << std::endl;
362 std::cout <<
"evaluate chi2 using function " << &func <<
" " << p << std::endl;
363 std::cout <<
"use empty bins " << fitOpt.
fUseEmpty << std::endl;
364 std::cout <<
"use integral " << fitOpt.
fIntegral << std::endl;
365 std::cout <<
"use all error=1 " << fitOpt.
fErrors1 << std::endl;
368 #ifdef USE_PARAMCACHE
369 IntegralEvaluator<> igEval( func, 0, useBinIntegral);
371 IntegralEvaluator<> igEval( func, p, useBinIntegral);
374 double wrefVolume = 1.0;
375 std::vector<double> xc;
378 xc.resize(data.
NDim() );
382 for (
unsigned int i = 0; i <
n; ++ i) {
384 double y = 0, invError = 1.;
387 const double *
x1 = data.
GetPoint(i,y, invError);
391 double binVolume = 1.0;
393 unsigned int ndim = data.
NDim();
395 for (
unsigned int j = 0; j < ndim; ++j) {
396 binVolume *=
std::abs( x2[j]-x1[j] );
397 xc[j] = 0.5*(x2[j]+ x1[j]);
400 binVolume *= wrefVolume;
403 const double *
x = (useBinVolume) ? &xc.front() :
x1;
405 if (!useBinIntegral) {
406 #ifdef USE_PARAMCACHE
409 fval =
func ( x, p );
418 if (useBinVolume) fval *= binVolume;
424 double invWeight = y * invError * invError;
427 double invError2 = (fval > 0) ? invWeight / fval : 0.0;
433 std::cout << x[0] <<
" " << y <<
" " << 1./invError <<
" params : ";
434 for (
unsigned int ipar = 0; ipar < func.
NPar(); ++ipar)
435 std::cout << p[ipar] <<
"\t";
436 std::cout <<
"\tfval = " << fval <<
" bin volume " << binVolume <<
" ref " << wrefVolume << std::endl;
444 double tmp = ( y -fval )* invError;
445 double resval = tmp * tmp;
449 if ( resval < maxResValue )
462 std::cout <<
"chi2 = " << chi2 <<
" n = " << nPoints << std::endl;
478 unsigned int n = data.
Size();
481 std::cout <<
"\n\nFit data size = " << n << std::endl;
482 std::cout <<
"evaluate effective chi2 using function " << &func <<
" " << p << std::endl;
493 unsigned int ndim = func.
NDim();
502 for (
unsigned int i = 0; i <
n; ++ i) {
508 double fval =
func( x, p );
510 double delta_y_func = y - fval;
514 const double *
ex = 0;
518 double eylow, eyhigh = 0;
520 if ( delta_y_func < 0)
528 while ( j < ndim && ex[j] == 0.) { j++; }
535 double kPrecision = 1.E-8;
536 for (
unsigned int icoord = 0; icoord < ndim; ++icoord) {
538 if (ex[icoord] > 0) {
542 double x0= x[icoord];
544 double deriv = derivator.
Derivative1(f1D, x[icoord], h);
545 double edx = ex[icoord] * deriv;
548 std::cout <<
"error for coord " << icoord <<
" = " << ex[icoord] <<
" deriv " << deriv << std::endl;
553 double w2 = (e2 > 0) ? 1.0/e2 : 0;
554 double resval = w2 * ( y - fval ) * ( y - fval);
557 std::cout << x[0] <<
" " << y <<
" ex " << ex[0] <<
" ey " << ey <<
" params : ";
558 for (
unsigned int ipar = 0; ipar < func.
NPar(); ++ipar)
559 std::cout << p[ipar] <<
"\t";
560 std::cout <<
"\tfval = " << fval <<
"\tresval = " << resval << std::endl;
565 if ( resval < maxResValue )
578 std::cout <<
"chi2 = " << chi2 <<
" n = " << nPoints << std::endl;
595 MATH_ERROR_MSG(
"FitUtil::EvaluateChi2Residual",
"Error on the coordinates are not used in calculating Chi2 residual");
602 double y, invError = 0;
609 const double *
x1 = data.
GetPoint(i,y, invError);
611 IntegralEvaluator<> igEval( func, p, useBinIntegral);
613 unsigned int ndim = data.
NDim();
614 double binVolume = 1.0;
615 const double *
x2 = 0;
616 if (useBinVolume || useBinIntegral) x2 = data.
BinUpEdge(i);
621 xc =
new double[ndim];
622 for (
unsigned int j = 0; j < ndim; ++j) {
623 binVolume *=
std::abs( x2[j]-x1[j] );
624 xc[j] = 0.5*(x2[j]+ x1[j]);
630 const double *
x = (useBinVolume) ? xc : x1;
632 if (!useBinIntegral) {
633 fval =
func ( x, p );
638 fval = igEval( x1, x2) ;
641 if (useBinVolume) fval *= binVolume;
647 double invWeight = y * invError * invError;
650 double invError2 = (fval > 0) ? invWeight / fval : 0.0;
655 double resval = ( y -fval )* invError;
663 unsigned int npar = func.
NPar();
668 if (!useBinIntegral ) {
677 SimpleGradientCalculator gc( npar, func);
678 if (!useBinIntegral )
679 gc.ParameterGradient(x, p, fval, g);
686 for (
unsigned int k = 0; k < npar; ++k) {
688 if (useBinVolume) g[k] *= binVolume;
692 if (useBinVolume)
delete [] xc;
706 MATH_ERROR_MSG(
"FitUtil::EvaluateChi2Residual",
"Error on the coordinates are not used in calculating Chi2 gradient");
return;
709 unsigned int nRejected = 0;
715 unsigned int n = data.
Size();
719 std::cout <<
"\n\nFit data size = " << n << std::endl;
720 std::cout <<
"evaluate chi2 using function gradient " << &func <<
" " << p << std::endl;
727 double wrefVolume = 1.0;
728 std::vector<double> xc;
731 xc.resize(data.
NDim() );
734 IntegralEvaluator<> igEval( func, p, useBinIntegral);
739 unsigned int npar = func.
NPar();
741 std::vector<double> gradFunc( npar );
743 std::vector<double>
g( npar);
745 for (
unsigned int i = 0; i <
n; ++ i) {
748 double y, invError = 0;
749 const double *
x1 = data.
GetPoint(i,y, invError);
752 const double *
x2 = 0;
754 double binVolume = 1;
756 unsigned int ndim = data.
NDim();
758 for (
unsigned int j = 0; j < ndim; ++j) {
759 binVolume *=
std::abs( x2[j]-x1[j] );
760 xc[j] = 0.5*(x2[j]+ x1[j]);
763 binVolume *= wrefVolume;
766 const double *
x = (useBinVolume) ? &xc.front() :
x1;
768 if (!useBinIntegral ) {
769 fval =
func ( x, p );
776 fval = igEval( x1, x2 ) ;
779 if (useBinVolume) fval *= binVolume;
782 std::cout << x[0] <<
" " << y <<
" " << 1./invError <<
" params : ";
783 for (
unsigned int ipar = 0; ipar < npar; ++ipar)
784 std::cout << p[ipar] <<
"\t";
785 std::cout <<
"\tfval = " << fval << std::endl;
793 unsigned int ipar = 0;
794 for ( ; ipar < npar ; ++ipar) {
797 if (useBinVolume) gradFunc[ipar] *= binVolume;
801 double dfval = gradFunc[ipar];
807 double tmp = - 2.0 * ( y -fval )* invError * invError * gradFunc[ipar];
823 if (nRejected != 0) {
825 nPoints = n - nRejected;
826 if (nPoints < npar)
MATH_ERROR_MSG(
"FitUtil::EvaluateChi2Gradient",
"Error - too many points rejected for overflow in gradient calculation");
830 std::copy(g.begin(), g.end(), grad);
851 const double *
x = data.
Coords(i);
852 double fval =
func ( x, p );
855 if (g == 0)
return logPdf;
867 SimpleGradientCalculator gc(func.
NPar(),
func);
868 gc.ParameterGradient(x, p, fval, g );
871 for (
unsigned int ipar = 0; ipar < func.
NPar(); ++ipar) {
876 std::cout << x[i] <<
"\t";
877 std::cout <<
"\tpar = [ " << func.
NPar() <<
" ] = ";
878 for (
unsigned int ipar = 0; ipar < func.
NPar(); ++ipar)
879 std::cout << p[ipar] <<
"\t";
880 std::cout <<
"\tfval = " << fval;
881 std::cout <<
"\tgrad = [ ";
882 for (
unsigned int ipar = 0; ipar < func.
NPar(); ++ipar)
883 std::cout << g[ipar] <<
"\t";
884 std::cout <<
" ] " << std::endl;
892 int iWeight,
bool extended,
unsigned int &nPoints) {
895 unsigned int n = data.
Size();
898 std::cout <<
"\n\nFit data size = " << n << std::endl;
899 std::cout <<
"func pointer is " <<
typeid(
func).
name() << std::endl;
906 #ifdef USE_PARAMCACHE
911 bool normalizeFunc =
false;
915 std::vector<double>
xmin(data.
NDim());
916 std::vector<double>
xmax(data.
NDim());
917 IntegralEvaluator<> igEval( func, p,
true);
919 norm = igEval.Integral(&
xmin[0],&
xmax[0]);
926 for (
unsigned int i = 0; i <
n; ++ i) {
927 const double *
x = data.
Coords(i);
928 #ifdef USE_PARAMCACHE
929 double fval =
func ( x );
931 double fval =
func ( x, p );
933 if (normalizeFunc) fval = fval /
norm;
936 std::cout <<
"x [ " << data.
NDim() <<
" ] = ";
937 for (
unsigned int j = 0; j < data.
NDim(); ++j)
938 std::cout << x[j] <<
"\t";
939 std::cout <<
"\tpar = [ " << func.
NPar() <<
" ] = ";
940 for (
unsigned int ipar = 0; ipar < func.
NPar(); ++ipar)
941 std::cout << p[ipar] <<
"\t";
942 std::cout <<
"\tfval = " << fval << std::endl;
947 double weight = data.
Weight(i);
954 sumW2 += weight*weight;
963 double extendedTerm = 0;
967 if (!normalizeFunc) {
968 IntegralEvaluator<> igEval( func, p,
true);
969 std::vector<double>
xmin(data.
NDim());
970 std::vector<double>
xmax(data.
NDim());
972 nuTot = igEval.Integral( &
xmin[0], &
xmax[0]);
976 extendedTerm = - nuTot;
980 extendedTerm = - (sumW2 / sumW) * nuTot;
989 logl += extendedTerm;
995 std::cout <<
"fit is extended n = " << n <<
" nutot " << nuTot <<
" extended LL term = " << extendedTerm <<
" logl = " << logl
1010 std::cout <<
"Logl = " << logl <<
" np = " << nPoints << std::endl;
1023 unsigned int n = data.
Size();
1026 unsigned int npar = func.
NPar();
1027 std::vector<double> gradFunc( npar );
1028 std::vector<double>
g( npar);
1030 for (
unsigned int i = 0; i <
n; ++ i) {
1031 const double *
x = data.
Coords(i);
1032 double fval =
func ( x , p);
1034 for (
unsigned int kpar = 0; kpar < npar; ++ kpar) {
1036 g[kpar] -= 1./fval * gradFunc[ kpar ];
1037 else if (gradFunc [ kpar] != 0) {
1040 double gg = kdmax1 * gradFunc[ kpar ];
1041 if ( gg > 0) gg =
std::min( gg, kdmax2);
1049 std::copy(g.begin(), g.end(), grad);
1066 IntegralEvaluator<> igEval( func, p, useBinIntegral);
1068 const double *
x2 = 0;
1070 double binVolume = 1;
1071 std::vector<double> xc;
1073 unsigned int ndim = data.
NDim();
1076 for (
unsigned int j = 0; j < ndim; ++j) {
1077 binVolume *=
std::abs( x2[j]-x1[j] );
1078 xc[j] = 0.5*(x2[j]+ x1[j]);
1084 const double *
x = (useBinVolume) ? &xc.front() :
x1;
1086 if (!useBinIntegral ) {
1087 fval =
func ( x, p );
1092 fval = igEval( x1, x2 ) ;
1094 if (useBinVolume) fval *= binVolume;
1098 double logPdf = - fval;
1108 if (g == 0)
return logPdf;
1110 unsigned int npar = func.
NPar();
1116 if (!useBinIntegral )
1125 SimpleGradientCalculator gc(func.
NPar(),
func);
1126 if (!useBinIntegral )
1127 gc.ParameterGradient(x, p, fval, g);
1134 for (
unsigned int k = 0; k < npar; ++k) {
1136 if (useBinVolume) g[k] *= binVolume;
1140 g[k] *= ( y/fval - 1.) ;
1151 std::cout <<
"x = " << x[0] <<
" logPdf = " << logPdf <<
" grad";
1152 for (
unsigned int ipar = 0; ipar < npar; ++ipar)
1153 std::cout << g[ipar] <<
"\t";
1154 std::cout << std::endl;
1162 const double * p,
int iWeight,
bool extended,
unsigned int & nPoints ) {
1180 unsigned int n = data.
Size();
1182 #ifdef USE_PARAMCACHE
1186 double nloglike = 0;
1194 bool useW2 = (iWeight == 2);
1197 double wrefVolume = 1.0;
1198 std::vector<double> xc;
1201 xc.resize(data.
NDim() );
1205 std::cout <<
"Evaluate PoissonLogL for params = [ ";
1206 for (
unsigned int j=0; j < func.
NPar(); ++j) std::cout << p[j] <<
" , ";
1207 std::cout <<
"] - data size = " << n <<
" useBinIntegral " << useBinIntegral <<
" useBinVolume "
1208 << useBinVolume <<
" useW2 " << useW2 <<
" wrefVolume = " << wrefVolume << std::endl;
1211 #ifdef USE_PARAMCACHE
1212 IntegralEvaluator<> igEval( func, 0, useBinIntegral);
1214 IntegralEvaluator<> igEval( func, p, useBinIntegral);
1221 for (
unsigned int i = 0; i <
n; ++ i) {
1222 const double *
x1 = data.
Coords(i);
1223 double y = data.
Value(i);
1226 double binVolume = 1.0;
1229 unsigned int ndim = data.
NDim();
1231 for (
unsigned int j = 0; j < ndim; ++j) {
1232 binVolume *=
std::abs( x2[j]-x1[j] );
1233 xc[j] = 0.5*(x2[j]+ x1[j]);
1236 binVolume *= wrefVolume;
1239 const double *
x = (useBinVolume) ? &xc.front() :
x1;
1241 if (!useBinIntegral) {
1242 #ifdef USE_PARAMCACHE
1245 fval =
func ( x, p );
1253 if (useBinVolume) fval *= binVolume;
1259 if (i%NSAMPLE == 0) {
1260 std::cout <<
"evt " << i <<
" x1 = [ ";
1261 for (
unsigned int j=0; j < func.
NDim(); ++j) std::cout << x[j] <<
" , ";
1264 std::cout <<
"x2 = [ ";
1265 for (
unsigned int j=0; j < func.
NDim(); ++j) std::cout << data.
BinUpEdge(i)[j] <<
" , ";
1268 std::cout <<
" y = " << y <<
" fval = " << fval << std::endl;
1286 double error = data.
Error(i);
1287 double weight = (error*error)/y;
1289 tmp = fval * weight;
1307 if (extended) tmp = fval -
y ;
1336 std::cout <<
"Loglikelihood = " << nloglike << std::endl;
1349 unsigned int n = data.
Size();
1355 double wrefVolume = 1.0;
1356 std::vector<double> xc;
1359 xc.resize(data.
NDim() );
1362 IntegralEvaluator<> igEval( func, p, useBinIntegral);
1364 unsigned int npar = func.
NPar();
1365 std::vector<double> gradFunc( npar );
1366 std::vector<double>
g( npar);
1368 for (
unsigned int i = 0; i <
n; ++ i) {
1369 const double *
x1 = data.
Coords(i);
1370 double y = data.
Value(i);
1372 const double *
x2 = 0;
1374 double binVolume = 1.0;
1377 unsigned int ndim = data.
NDim();
1378 for (
unsigned int j = 0; j < ndim; ++j) {
1379 binVolume *=
std::abs( x2[j]-x1[j] );
1380 xc[j] = 0.5*(x2[j]+ x1[j]);
1383 binVolume *= wrefVolume;
1386 const double *
x = (useBinVolume) ? &xc.front() :
x1;
1388 if (!useBinIntegral) {
1389 fval =
func ( x, p );
1396 fval = igEval( x1, x2) ;
1399 if (useBinVolume) fval *= binVolume;
1402 for (
unsigned int kpar = 0; kpar < npar; ++ kpar) {
1405 if (useBinVolume) gradFunc[kpar] *= binVolume;
1409 g[kpar] += gradFunc[ kpar ] * ( 1. - y/fval );
1410 else if (gradFunc [ kpar] != 0) {
1413 double gg = kdmax1 * gradFunc[ kpar ];
1414 if ( gg > 0) gg =
std::min( gg, kdmax2);
1421 std::copy(g.begin(), g.end(), grad);
ErrorType GetErrorType() const
bool CheckValue(double &rval)
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
void EvaluateChi2Gradient(const IModelFunction &func, const BinData &data, const double *x, double *grad, unsigned int &nPoints)
evaluate the Chi2 gradient given a model function and the data at the point x.
Namespace for new ROOT classes and functions.
double RefVolume() const
retrieve the reference volume used to normalize the data when the option bin volume is set ...
double EvaluatePoissonBinPdf(const IModelFunction &func, const BinData &data, const double *x, unsigned int ipoint, double *g=0)
evaluate the pdf contribution to the Poisson LogL given a model function and the BinPoint data...
void CalculateGradientIntegral(const GFunc &gfunc, const double *x1, const double *x2, const double *p, double *g)
double Weight(unsigned int ipoint) const
unsigned int NDim() const
return coordinate data dimension
virtual void ParameterGradient(const double *x, const double *p, double *grad) const
Evaluate the all the derivatives (gradient vector) of the function with respect to the parameters at ...
Class describing the unbinned data sets (just x coordinates values) of any dimensions.
bool HaveAsymErrors() const
flag to control if data provides asymmetric errors on the value
unsigned int Size() const
return number of fit points
double SumOfError2() const
compute the total sum of the error square (sum of weight square in case of a weighted data set) ...
static const double x2[5]
const double * BinUpEdge(unsigned int icoord) const
return an array containing the upper edge of the bin for coordinate i In case of empty bin they could...
void EvaluatePoissonLogLGradient(const IModelFunction &func, const BinData &data, const double *x, double *grad)
evaluate the Poisson LogL given a model function and the data at the point x.
void SetParameters(TFitEditor::FuncParams_t &pars, TF1 *func)
Restore the parameters from pars into the function.
OneDimMultiFunctionAdapter class to wrap a multidimensional function in one dimensional one...
static Vc_ALWAYS_INLINE Vector< T > abs(const Vector< T > &x)
double Derivative1(double x)
Returns the first derivative of the function at point x, computed by Richardson's extrapolation metho...
double SumOfContent() const
compute the total sum of the data content (sum of weights in cse of weighted data set) ...
void EvaluateLogLGradient(const IModelFunction &func, const UnBinData &data, const double *x, double *grad, unsigned int &nPoints)
evaluate the LogL gradient given a model function and the data at the point x.
#define MATH_ERROR_MSG(loc, str)
virtual unsigned int NPar() const =0
Return the number of Parameters.
DataOptions : simple structure holding the options on how the data are filled.
IParamFunction interface (abstract class) describing multi-dimensional parameteric functions It is a ...
double EvaluateChi2Effective(const IModelFunction &func, const BinData &data, const double *x, unsigned int &nPoints)
evaluate the effective Chi2 given a model function and the data at the point x.
const DataRange & Range() const
access to range
virtual unsigned int NDim() const =0
Retrieve the dimension of the function.
double EvaluateLogL(const IModelFunction &func, const UnBinData &data, const double *x, int iWeight, bool extended, unsigned int &nPoints)
evaluate the LogL given a model function and the data at the point x.
double EvaluateChi2Residual(const IModelFunction &func, const BinData &data, const double *x, unsigned int ipoint, double *g=0)
Parallel evaluate the Chi2 given a model function and the data at the point x.
User Class for performing numerical integration of a function in one dimension.
const double * Coords(unsigned int ipoint) const
return a pointer to the coordinates data for the given fit point
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
double EvaluatePoissonLogL(const IModelFunction &func, const BinData &data, const double *x, int iWeight, bool extended, unsigned int &nPoints)
evaluate the Poisson LogL given a model function and the data at the point x.
ROOT::Math::IParamMultiFunction IModelFunction
double EvaluateChi2(const IModelFunction &func, const BinData &data, const double *x, unsigned int &nPoints)
Chi2 Functions.
double CorrectValue(double rval)
TRObject operator()(const T1 &t1) const
static const double x1[5]
const double * Coords(unsigned int ipoint) const
return pointer to coordinate data
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Interface (abstract class) for parametric gradient multi-dimensional functions providing in addition ...
double EvaluatePdf(const IModelFunction &func, const UnBinData &data, const double *x, unsigned int ipoint, double *g=0)
evaluate the pdf contribution to the LogL given a model function and the BinPoint data...
double func(double *x, double *p)
double Error(unsigned int ipoint) const
return error on the value for the given fit point Safe (but slower) method returning correctly the er...
double Value(unsigned int ipoint) const
return the value for the given fit point
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
bool HasBinEdges() const
query if the data store the bin edges instead of the center
Binding & operator=(OUT(*fun)(void))
double EvalLog(double x)
safe evaluation of log(x) with a protections against negative or zero argument to the log smooth line...
User class for performing multidimensional integration.
double f2(const double *x)
const DataOptions & Opt() const
access to options
void SetCoord(int icoord)
unsigned int Size() const
return number of contained points
const double * GetPoint(unsigned int ipoint, double &value) const
retrieve at the same time a pointer to the coordinate data and the fit value More efficient than call...
Documentation for the abstract class IBaseFunctionMultiDim.
bool HaveCoordErrors() const
flag to control if data provides error on the coordinates
double norm(double *x, double *p)
void GetRange(unsigned int icoord, double &xmin, double &xmax) const
get the first range for given coordinate.
Template class to wrap any member function of a class taking a double and returning a double in a 1D ...
User class for calculating the derivatives of a function.
unsigned int NDim() const
return coordinate data dimension
const double * GetPointError(unsigned int ipoint, double &errvalue) const
Retrieve the errors on the point (coordinate and value) for the given fit point It must be called onl...