43 #define USE_PARAMCACHE 59 template <
class ParamFunc = ROOT::Math::IParamMultiFunction>
60 class IntegralEvaluator {
64 IntegralEvaluator(
const ParamFunc &
func,
const double * p,
bool useIntegral =
true) :
78 void SetFunction(
const ParamFunc & func,
const double * p = 0) {
93 fIg1Dim->SetFunction( static_cast<const ROOT::Math::IGenFunction &>(*fFunc1Dim) );
98 fIgNDim->SetFunction(*fFuncNDim);
109 ~IntegralEvaluator() {
110 if (fIg1Dim)
delete fIg1Dim;
111 if (fIgNDim)
delete fIgNDim;
112 if (fFunc1Dim)
delete fFunc1Dim;
113 if (fFuncNDim)
delete fFuncNDim;
118 double F1 (
double x)
const {
119 double xx[1]; xx[0] =
x;
120 return (*fFunc)( xx, fParams);
123 double FN(
const double * x)
const {
124 return (*fFunc)(
x, fParams);
127 double Integral(
const double *
x1,
const double *
x2) {
129 return (fIg1Dim) ? fIg1Dim->Integral( *x1, *x2) : fIgNDim->Integral( x1, x2);
131 double operator()(
const double *x1,
const double * x2) {
134 double dV = *x2 - *
x1;
135 return fIg1Dim->Integral( *x1, *x2)/dV;
139 for (
unsigned int i = 0; i < fDim; ++i)
140 dV *= ( x2[i] - x1[i] );
141 return fIgNDim->Integral( x1, x2)/dV;
153 IntegralEvaluator(
const IntegralEvaluator& rhs);
154 IntegralEvaluator&
operator=(
const IntegralEvaluator& rhs);
157 const double * fParams;
159 const ParamFunc * fFunc;
168 template<
class GradFunc = IGradModelFunction>
169 struct ParamDerivFunc {
170 ParamDerivFunc(
const GradFunc &
f) : fFunc(f), fIpar(0) {}
171 void SetDerivComponent(
unsigned int ipar) { fIpar = ipar; }
172 double operator() (
const double *
x,
const double *p)
const {
173 return fFunc.ParameterDerivative( x, p, fIpar );
175 unsigned int NDim()
const {
return fFunc.NDim(); }
176 const GradFunc & fFunc;
182 class SimpleGradientCalculator {
192 SimpleGradientCalculator(
int gdim,
const IModelFunction &
func,
double eps = 2.
E-8,
int istrat = 1) :
198 fVec(std::vector<double>(gdim) )
203 double DoParameterDerivative(
const double *
x,
const double *p,
double f0,
int k)
const {
205 double h = std::max( fEps* std::abs(p0), 8.0*fPrecision*(std::abs(p0) + fPrecision) );
210 double f1 = fFunc(x, &fVec.front() );
213 double f2 = fFunc(x, &fVec.front() );
214 deriv = 0.5 * ( f2 -
f1 )/h;
217 deriv = ( f1 - f0 )/h;
223 unsigned int NDim()
const {
227 unsigned int NPar()
const {
231 double ParameterDerivative(
const double *x,
const double *p,
int ipar)
const {
233 std::copy(p, p+fN, fVec.begin());
234 double f0 = fFunc(x, p);
235 return DoParameterDerivative(x,p,f0,ipar);
239 void ParameterGradient(
const double * x,
const double * p,
double f0,
double * g) {
241 std::copy(p, p+fN, fVec.begin());
242 for (
unsigned int k = 0; k < fN; ++k) {
243 g[k] = DoParameterDerivative(x,p,f0,k);
248 void Gradient(
const double * x,
const double * p,
double f0,
double * g) {
250 std::copy(x, x+fN, fVec.begin());
251 for (
unsigned int k = 0; k < fN; ++k) {
253 double h = std::max( fEps* std::abs(x0), 8.0*fPrecision*(std::abs(x0) + fPrecision) );
257 double f1 = fFunc( &fVec.front(), p );
260 double f2 = fFunc( &fVec.front(), p );
261 g[k] = 0.5 * ( f2 -
f1 )/h;
264 g[k] = ( f1 - f0 )/h;
277 mutable std::vector<double> fVec;
284 if (rval > - std::numeric_limits<double>::max() && rval < std::numeric_limits<double>::max() )
288 return -std::numeric_limits<double>::max();
291 return + std::numeric_limits<double>::max();
294 if (rval > - std::numeric_limits<double>::max() && rval < std::numeric_limits<double>::max() )
298 rval = -std::numeric_limits<double>::max();
303 rval = + std::numeric_limits<double>::max();
312 template <
class GFunc>
314 const double *
x1,
const double *
x2,
const double * p,
double *g) {
317 ParamDerivFunc<GFunc> pfunc( gfunc);
318 IntegralEvaluator<ParamDerivFunc<GFunc> > igDerEval( pfunc, p,
true);
320 unsigned int npar = gfunc.NPar();
321 for (
unsigned int k = 0; k < npar; ++k ) {
322 pfunc.SetDerivComponent(k);
323 g[k] = igDerEval( x1, x2 );
343 unsigned int n = data.
Size();
348 #ifdef USE_PARAMCACHE 362 std::cout <<
"\n\nFit data size = " << n << std::endl;
363 std::cout <<
"evaluate chi2 using function " << &func <<
" " << p << std::endl;
364 std::cout <<
"use empty bins " << fitOpt.
fUseEmpty << std::endl;
365 std::cout <<
"use integral " << fitOpt.
fIntegral << std::endl;
366 std::cout <<
"use all error=1 " << fitOpt.
fErrors1 << std::endl;
369 #ifdef USE_PARAMCACHE 370 IntegralEvaluator<> igEval( func, 0, useBinIntegral);
372 IntegralEvaluator<> igEval( func, p, useBinIntegral);
374 double maxResValue = std::numeric_limits<double>::max() /
n;
375 double wrefVolume = 1.0;
376 std::vector<double> xc;
379 xc.resize(data.
NDim() );
383 for (
unsigned int i = 0; i <
n; ++ i) {
385 double y = 0, invError = 1.;
388 const double *
x1 = data.
GetPoint(i,y, invError);
392 double binVolume = 1.0;
394 unsigned int ndim = data.
NDim();
396 for (
unsigned int j = 0; j < ndim; ++j) {
397 binVolume *= std::abs( x2[j]-x1[j] );
398 xc[j] = 0.5*(x2[j]+ x1[j]);
401 binVolume *= wrefVolume;
404 const double *
x = (useBinVolume) ? &xc.front() :
x1;
406 if (!useBinIntegral) {
407 #ifdef USE_PARAMCACHE 410 fval =
func ( x, p );
419 if (useBinVolume) fval *= binVolume;
425 double invWeight = y * invError * invError;
428 double invError2 = (fval > 0) ? invWeight / fval : 0.0;
434 std::cout << x[0] <<
" " << y <<
" " << 1./invError <<
" params : ";
435 for (
unsigned int ipar = 0; ipar < func.
NPar(); ++ipar)
436 std::cout << p[ipar] <<
"\t";
437 std::cout <<
"\tfval = " << fval <<
" bin volume " << binVolume <<
" ref " << wrefVolume << std::endl;
445 double tmp = ( y -fval )* invError;
446 double resval = tmp * tmp;
450 if ( resval < maxResValue )
463 std::cout <<
"chi2 = " << chi2 <<
" n = " << nPoints << std::endl;
479 unsigned int n = data.
Size();
482 std::cout <<
"\n\nFit data size = " << n << std::endl;
483 std::cout <<
"evaluate effective chi2 using function " << &func <<
" " << p << std::endl;
494 unsigned int ndim = func.
NDim();
499 double maxResValue = std::numeric_limits<double>::max() /
n;
503 for (
unsigned int i = 0; i <
n; ++ i) {
509 double fval =
func( x, p );
511 double delta_y_func = y - fval;
515 const double *
ex = 0;
519 double eylow, eyhigh = 0;
521 if ( delta_y_func < 0)
529 while ( j < ndim && ex[j] == 0.) { j++; }
536 double kPrecision = 1.E-8;
537 for (
unsigned int icoord = 0; icoord < ndim; ++icoord) {
539 if (ex[icoord] > 0) {
543 double x0= x[icoord];
544 double h = std::max( kEps* std::abs(ex[icoord]), 8.0*kPrecision*(std::abs(x0) + kPrecision) );
545 double deriv = derivator.
Derivative1(f1D, x[icoord], h);
546 double edx = ex[icoord] * deriv;
549 std::cout <<
"error for coord " << icoord <<
" = " << ex[icoord] <<
" deriv " << deriv << std::endl;
554 double w2 = (e2 > 0) ? 1.0/e2 : 0;
555 double resval = w2 * ( y - fval ) * ( y - fval);
558 std::cout << x[0] <<
" " << y <<
" ex " << ex[0] <<
" ey " << ey <<
" params : ";
559 for (
unsigned int ipar = 0; ipar < func.
NPar(); ++ipar)
560 std::cout << p[ipar] <<
"\t";
561 std::cout <<
"\tfval = " << fval <<
"\tresval = " << resval << std::endl;
566 if ( resval < maxResValue )
579 std::cout <<
"chi2 = " << chi2 <<
" n = " << nPoints << std::endl;
596 MATH_ERROR_MSG(
"FitUtil::EvaluateChi2Residual",
"Error on the coordinates are not used in calculating Chi2 residual");
603 double y, invError = 0;
610 const double *
x1 = data.
GetPoint(i,y, invError);
612 IntegralEvaluator<> igEval( func, p, useBinIntegral);
614 unsigned int ndim = data.
NDim();
615 double binVolume = 1.0;
616 const double *
x2 = 0;
617 if (useBinVolume || useBinIntegral) x2 = data.
BinUpEdge(i);
622 xc =
new double[ndim];
623 for (
unsigned int j = 0; j < ndim; ++j) {
624 binVolume *= std::abs( x2[j]-x1[j] );
625 xc[j] = 0.5*(x2[j]+ x1[j]);
631 const double *
x = (useBinVolume) ? xc : x1;
633 if (!useBinIntegral) {
634 fval =
func ( x, p );
639 fval = igEval( x1, x2) ;
642 if (useBinVolume) fval *= binVolume;
648 double invWeight = y * invError * invError;
651 double invError2 = (fval > 0) ? invWeight / fval : 0.0;
656 double resval = ( y -fval )* invError;
664 unsigned int npar = func.
NPar();
669 if (!useBinIntegral ) {
678 SimpleGradientCalculator gc( npar, func);
679 if (!useBinIntegral )
680 gc.ParameterGradient(x, p, fval, g);
687 for (
unsigned int k = 0; k < npar; ++k) {
689 if (useBinVolume) g[k] *= binVolume;
693 if (useBinVolume)
delete [] xc;
707 MATH_ERROR_MSG(
"FitUtil::EvaluateChi2Residual",
"Error on the coordinates are not used in calculating Chi2 gradient");
return;
710 unsigned int nRejected = 0;
716 unsigned int n = data.
Size();
720 std::cout <<
"\n\nFit data size = " << n << std::endl;
721 std::cout <<
"evaluate chi2 using function gradient " << &func <<
" " << p << std::endl;
728 double wrefVolume = 1.0;
729 std::vector<double> xc;
732 xc.resize(data.
NDim() );
735 IntegralEvaluator<> igEval( func, p, useBinIntegral);
740 unsigned int npar = func.
NPar();
742 std::vector<double> gradFunc( npar );
744 std::vector<double> g( npar);
746 for (
unsigned int i = 0; i <
n; ++ i) {
749 double y, invError = 0;
750 const double *
x1 = data.
GetPoint(i,y, invError);
753 const double *
x2 = 0;
755 double binVolume = 1;
757 unsigned int ndim = data.
NDim();
759 for (
unsigned int j = 0; j < ndim; ++j) {
760 binVolume *= std::abs( x2[j]-x1[j] );
761 xc[j] = 0.5*(x2[j]+ x1[j]);
764 binVolume *= wrefVolume;
767 const double *
x = (useBinVolume) ? &xc.front() :
x1;
769 if (!useBinIntegral ) {
770 fval =
func ( x, p );
777 fval = igEval( x1, x2 ) ;
780 if (useBinVolume) fval *= binVolume;
783 std::cout << x[0] <<
" " << y <<
" " << 1./invError <<
" params : ";
784 for (
unsigned int ipar = 0; ipar < npar; ++ipar)
785 std::cout << p[ipar] <<
"\t";
786 std::cout <<
"\tfval = " << fval << std::endl;
794 unsigned int ipar = 0;
795 for ( ; ipar < npar ; ++ipar) {
798 if (useBinVolume) gradFunc[ipar] *= binVolume;
802 double dfval = gradFunc[ipar];
808 double tmp = - 2.0 * ( y -fval )* invError * invError * gradFunc[ipar];
824 if (nRejected != 0) {
825 assert(nRejected <= n);
826 nPoints = n - nRejected;
827 if (nPoints < npar)
MATH_ERROR_MSG(
"FitUtil::EvaluateChi2Gradient",
"Error - too many points rejected for overflow in gradient calculation");
831 std::copy(g.begin(), g.end(), grad);
852 const double *
x = data.
Coords(i);
853 double fval =
func ( x, p );
856 if (g == 0)
return logPdf;
868 SimpleGradientCalculator gc(func.
NPar(),
func);
869 gc.ParameterGradient(x, p, fval, g );
872 for (
unsigned int ipar = 0; ipar < func.
NPar(); ++ipar) {
877 std::cout << x[i] <<
"\t";
878 std::cout <<
"\tpar = [ " << func.
NPar() <<
" ] = ";
879 for (
unsigned int ipar = 0; ipar < func.
NPar(); ++ipar)
880 std::cout << p[ipar] <<
"\t";
881 std::cout <<
"\tfval = " << fval;
882 std::cout <<
"\tgrad = [ ";
883 for (
unsigned int ipar = 0; ipar < func.
NPar(); ++ipar)
884 std::cout << g[ipar] <<
"\t";
885 std::cout <<
" ] " << std::endl;
893 int iWeight,
bool extended,
unsigned int &nPoints) {
896 unsigned int n = data.
Size();
899 std::cout <<
"\n\nFit data size = " << n << std::endl;
900 std::cout <<
"func pointer is " <<
typeid(
func).
name() << std::endl;
907 #ifdef USE_PARAMCACHE 912 bool normalizeFunc =
false;
916 std::vector<double>
xmin(data.
NDim());
917 std::vector<double>
xmax(data.
NDim());
918 IntegralEvaluator<> igEval( func, p,
true);
922 for (
unsigned int ir = 0; ir < data.
Range().
Size(); ++ir) {
924 norm += igEval.Integral(
xmin.data(),
xmax.data());
931 MATH_ERROR_MSG(
"FitUtil::EvaluateLogLikelihood",
"A range has not been set and the function is not zero at +/- inf");
934 norm = igEval.Integral(&
xmin[0],&
xmax[0]);
942 for (
unsigned int i = 0; i <
n; ++ i) {
943 const double *
x = data.
Coords(i);
944 #ifdef USE_PARAMCACHE 945 double fval =
func ( x );
947 double fval =
func ( x, p );
949 if (normalizeFunc) fval = fval /
norm;
953 std::cout <<
"x [ " << data.
NDim() <<
" ] = ";
954 for (
unsigned int j = 0; j < data.
NDim(); ++j)
955 std::cout << x[j] <<
"\t";
956 std::cout <<
"\tpar = [ " << func.
NPar() <<
" ] = ";
957 for (
unsigned int ipar = 0; ipar < func.
NPar(); ++ipar)
958 std::cout << p[ipar] <<
"\t";
959 std::cout <<
"\tfval = " << fval << std::endl;
967 double weight = data.
Weight(i);
974 sumW2 += weight*weight;
982 std::cout << std::endl;
987 double extendedTerm = 0;
991 if (!normalizeFunc) {
992 IntegralEvaluator<> igEval( func, p,
true);
993 std::vector<double>
xmin(data.
NDim());
994 std::vector<double>
xmax(data.
NDim());
999 for (
unsigned int ir = 0; ir < data.
Range().
Size(); ++ir) {
1001 nuTot += igEval.Integral(
xmin.data(),
xmax.data());
1003 std::cout <<
"After Integral bewteen " <<
xmin[0] <<
" and " <<
xmax[0] <<
" nexp is " << nuTot << std::endl;
1011 MATH_ERROR_MSG(
"FitUtil::EvaluateLogLikelihood",
"A range has not been set and the function is not zero at +/- inf");
1014 nuTot = igEval.Integral(&
xmin[0],&
xmax[0]);
1016 std::cout <<
"Range not existig - integral bewteen " <<
xmin[0] <<
" and " <<
xmax[0] <<
" is " << nuTot << std::endl;
1023 extendedTerm = - nuTot;
1027 extendedTerm = - (sumW2 / sumW) * nuTot;
1036 logl += extendedTerm;
1042 std::cout <<
"fit is extended n = " << n <<
" nutot " << nuTot <<
" extended LL term = " << extendedTerm <<
" logl = " << logl
1057 std::cout <<
"Logl = " << logl <<
" np = " << nPoints << std::endl;
1070 unsigned int n = data.
Size();
1073 unsigned int npar = func.
NPar();
1074 std::vector<double> gradFunc( npar );
1075 std::vector<double> g( npar);
1077 for (
unsigned int i = 0; i <
n; ++ i) {
1078 const double *
x = data.
Coords(i);
1079 double fval =
func ( x , p);
1081 for (
unsigned int kpar = 0; kpar < npar; ++ kpar) {
1083 g[kpar] -= 1./fval * gradFunc[ kpar ];
1084 else if (gradFunc [ kpar] != 0) {
1085 const double kdmax1 =
std::sqrt( std::numeric_limits<double>::max() );
1086 const double kdmax2 = std::numeric_limits<double>::max() / (4*
n);
1087 double gg = kdmax1 * gradFunc[ kpar ];
1088 if ( gg > 0) gg = std::min( gg, kdmax2);
1089 else gg = std::max(gg, - kdmax2);
1096 std::copy(g.begin(), g.end(), grad);
1113 IntegralEvaluator<> igEval( func, p, useBinIntegral);
1115 const double *
x2 = 0;
1117 double binVolume = 1;
1118 std::vector<double> xc;
1120 unsigned int ndim = data.
NDim();
1123 for (
unsigned int j = 0; j < ndim; ++j) {
1124 binVolume *= std::abs( x2[j]-x1[j] );
1125 xc[j] = 0.5*(x2[j]+ x1[j]);
1131 const double *
x = (useBinVolume) ? &xc.front() :
x1;
1133 if (!useBinIntegral ) {
1134 fval =
func ( x, p );
1139 fval = igEval( x1, x2 ) ;
1141 if (useBinVolume) fval *= binVolume;
1144 fval = std::max(fval, 0.0);
1145 double logPdf = - fval;
1155 if (g == 0)
return logPdf;
1157 unsigned int npar = func.
NPar();
1163 if (!useBinIntegral )
1172 SimpleGradientCalculator gc(func.
NPar(),
func);
1173 if (!useBinIntegral )
1174 gc.ParameterGradient(x, p, fval, g);
1181 for (
unsigned int k = 0; k < npar; ++k) {
1183 if (useBinVolume) g[k] *= binVolume;
1187 g[k] *= ( y/fval - 1.) ;
1189 const double kdmax1 =
std::sqrt( std::numeric_limits<double>::max() );
1198 std::cout <<
"x = " << x[0] <<
" logPdf = " << logPdf <<
" grad";
1199 for (
unsigned int ipar = 0; ipar < npar; ++ipar)
1200 std::cout << g[ipar] <<
"\t";
1201 std::cout << std::endl;
1209 const double * p,
int iWeight,
bool extended,
unsigned int & nPoints ) {
1227 unsigned int n = data.
Size();
1229 #ifdef USE_PARAMCACHE 1233 double nloglike = 0;
1241 bool useW2 = (iWeight == 2);
1244 double wrefVolume = 1.0;
1245 std::vector<double> xc;
1248 xc.resize(data.
NDim() );
1252 std::cout <<
"Evaluate PoissonLogL for params = [ ";
1253 for (
unsigned int j=0; j < func.
NPar(); ++j) std::cout << p[j] <<
" , ";
1254 std::cout <<
"] - data size = " << n <<
" useBinIntegral " << useBinIntegral <<
" useBinVolume " 1255 << useBinVolume <<
" useW2 " << useW2 <<
" wrefVolume = " << wrefVolume << std::endl;
1258 #ifdef USE_PARAMCACHE 1259 IntegralEvaluator<> igEval( func, 0, useBinIntegral);
1261 IntegralEvaluator<> igEval( func, p, useBinIntegral);
1268 for (
unsigned int i = 0; i <
n; ++ i) {
1269 const double *
x1 = data.
Coords(i);
1270 double y = data.
Value(i);
1273 double binVolume = 1.0;
1276 unsigned int ndim = data.
NDim();
1278 for (
unsigned int j = 0; j < ndim; ++j) {
1279 binVolume *= std::abs( x2[j]-x1[j] );
1280 xc[j] = 0.5*(x2[j]+ x1[j]);
1283 binVolume *= wrefVolume;
1286 const double *
x = (useBinVolume) ? &xc.front() :
x1;
1288 if (!useBinIntegral) {
1289 #ifdef USE_PARAMCACHE 1292 fval =
func ( x, p );
1300 if (useBinVolume) fval *= binVolume;
1306 if (i%NSAMPLE == 0) {
1307 std::cout <<
"evt " << i <<
" x1 = [ ";
1308 for (
unsigned int j=0; j < func.
NDim(); ++j) std::cout << x[j] <<
" , ";
1311 std::cout <<
"x2 = [ ";
1312 for (
unsigned int j=0; j < func.
NDim(); ++j) std::cout << data.
BinUpEdge(i)[j] <<
" , ";
1315 std::cout <<
" y = " << y <<
" fval = " << fval << std::endl;
1322 fval = std::max(fval, 0.0);
1333 double error = data.
Error(i);
1334 double weight = (error*error)/y;
1336 tmp = fval * weight;
1354 if (extended) tmp = fval -
y ;
1383 std::cout <<
"Loglikelihood = " << nloglike << std::endl;
1396 unsigned int n = data.
Size();
1402 double wrefVolume = 1.0;
1403 std::vector<double> xc;
1406 xc.resize(data.
NDim() );
1409 IntegralEvaluator<> igEval( func, p, useBinIntegral);
1411 unsigned int npar = func.
NPar();
1412 std::vector<double> gradFunc( npar );
1413 std::vector<double> g( npar);
1415 for (
unsigned int i = 0; i <
n; ++ i) {
1416 const double *
x1 = data.
Coords(i);
1417 double y = data.
Value(i);
1419 const double *
x2 = 0;
1421 double binVolume = 1.0;
1424 unsigned int ndim = data.
NDim();
1425 for (
unsigned int j = 0; j < ndim; ++j) {
1426 binVolume *= std::abs( x2[j]-x1[j] );
1427 xc[j] = 0.5*(x2[j]+ x1[j]);
1430 binVolume *= wrefVolume;
1433 const double *
x = (useBinVolume) ? &xc.front() :
x1;
1435 if (!useBinIntegral) {
1436 fval =
func ( x, p );
1443 fval = igEval( x1, x2) ;
1446 if (useBinVolume) fval *= binVolume;
1449 for (
unsigned int kpar = 0; kpar < npar; ++ kpar) {
1452 if (useBinVolume) gradFunc[kpar] *= binVolume;
1456 g[kpar] += gradFunc[ kpar ] * ( 1. - y/fval );
1457 else if (gradFunc [ kpar] != 0) {
1458 const double kdmax1 =
std::sqrt( std::numeric_limits<double>::max() );
1459 const double kdmax2 = std::numeric_limits<double>::max() / (4*
n);
1460 double gg = kdmax1 * gradFunc[ kpar ];
1461 if ( gg > 0) gg = std::min( gg, kdmax2);
1462 else gg = std::max(gg, - kdmax2);
1468 std::copy(g.begin(), g.end(), grad);
bool CheckValue(double &rval)
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
bool HaveAsymErrors() const
flag to control if data provides asymmetric errors on the value
unsigned int NDim() const
return coordinate data dimension
bool HasBinEdges() const
query if the data store the bin edges instead of the center
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.
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 ...
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)
ErrorType GetErrorType() const
retrieve the errortype
Class describing the unbinned data sets (just x coordinates values) of any dimensions.
Interface (abstract class) for parametric gradient multi-dimensional functions providing in addition ...
TRObject operator()(const T1 &t1) const
const double * Coords(unsigned int ipoint) const
return a pointer to the coordinates data for the given fit point
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...
static const double x2[5]
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.
void GetRange(unsigned int irange, unsigned int icoord, double &xmin, double &xmax) const
get the i-th range for given coordinate.
OneDimMultiFunctionAdapter class to wrap a multidimensional function in one dimensional one...
double RefVolume() const
retrieve the reference volume used to normalize the data when the option bin volume is set ...
double Derivative1(double x)
Returns the first derivative of the function at point x, computed by Richardson's extrapolation metho...
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.
unsigned int Size() const
return number of fit points
double Error(unsigned int ipoint) const
return error on the value for the given fit point Safe (but slower) method returning correctly the er...
#define MATH_ERROR_MSG(loc, str)
Documentation for the abstract class IBaseFunctionMultiDim.
virtual unsigned int NPar() const =0
Return the number of Parameters.
double Weight(unsigned int ipoint) const
return weight
DataOptions : simple structure holding the options on how the data are filled.
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 double * BinUpEdge(unsigned int ipoint) const
return an array containing the upper edge of the bin for coordinate i In case of empty bin they could...
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.
unsigned int Size(unsigned int icoord=0) const
return range size for coordinate icoord (starts from zero) Size == 0 indicates no range is present [-...
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 DataOptions & Opt() const
access to options
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.
bool HaveCoordErrors() const
flag to control if data provides error on the coordinates
ROOT::Math::IParamMultiFunction IModelFunction
double EvaluateChi2(const IModelFunction &func, const BinData &data, const double *x, unsigned int &nPoints)
Chi2 Functions.
double CorrectValue(double rval)
static const double x1[5]
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
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 Value(unsigned int ipoint) const
return the value for the given fit point
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 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...
void SetCoord(int icoord)
unsigned int NDim() const
return coordinate data dimension
const DataRange & Range() const
access to range
double norm(double *x, double *p)
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.
virtual unsigned int NDim() const =0
Retrieve the dimension of the function.