44 #define USE_PARAMCACHE 60 template <
class ParamFunc = ROOT::Math::IParamMultiFunction>
61 class IntegralEvaluator {
65 IntegralEvaluator(
const ParamFunc &
func,
const double * p,
bool useIntegral =
true) :
79 void SetFunction(
const ParamFunc & func,
const double * p = 0) {
94 fIg1Dim->SetFunction( static_cast<const ROOT::Math::IGenFunction &>(*fFunc1Dim) );
99 fIgNDim->SetFunction(*fFuncNDim);
110 ~IntegralEvaluator() {
111 if (fIg1Dim)
delete fIg1Dim;
112 if (fIgNDim)
delete fIgNDim;
113 if (fFunc1Dim)
delete fFunc1Dim;
114 if (fFuncNDim)
delete fFuncNDim;
119 double F1 (
double x)
const {
120 double xx[1]; xx[0] =
x;
121 return (*fFunc)( xx, fParams);
124 double FN(
const double * x)
const {
125 return (*fFunc)(
x, fParams);
128 double Integral(
const double *
x1,
const double *
x2) {
130 return (fIg1Dim) ? fIg1Dim->Integral( *x1, *x2) : fIgNDim->Integral( x1, x2);
132 double operator()(
const double *x1,
const double * x2) {
135 double dV = *x2 - *
x1;
136 return fIg1Dim->Integral( *x1, *x2)/dV;
140 for (
unsigned int i = 0; i < fDim; ++i)
141 dV *= ( x2[i] - x1[i] );
142 return fIgNDim->Integral( x1, x2)/dV;
154 IntegralEvaluator(
const IntegralEvaluator& rhs);
155 IntegralEvaluator& operator=(
const IntegralEvaluator& rhs);
158 const double * fParams;
160 const ParamFunc * fFunc;
169 template<
class GradFunc = IGradModelFunction>
170 struct ParamDerivFunc {
171 ParamDerivFunc(
const GradFunc &
f) : fFunc(f), fIpar(0) {}
172 void SetDerivComponent(
unsigned int ipar) { fIpar = ipar; }
173 double operator() (
const double *
x,
const double *p)
const {
174 return fFunc.ParameterDerivative( x, p, fIpar );
176 unsigned int NDim()
const {
return fFunc.NDim(); }
177 const GradFunc & fFunc;
183 class SimpleGradientCalculator {
193 SimpleGradientCalculator(
int gdim,
const IModelFunction &
func,
double eps = 2.
E-8,
int istrat = 1) :
199 fVec(std::vector<double>(gdim) )
204 double DoParameterDerivative(
const double *
x,
const double *p,
double f0,
int k)
const {
206 double h = std::max( fEps* std::abs(p0), 8.0*fPrecision*(std::abs(p0) + fPrecision) );
211 double f1 = fFunc(x, &fVec.front() );
214 double f2 = fFunc(x, &fVec.front() );
215 deriv = 0.5 * ( f2 -
f1 )/h;
218 deriv = ( f1 - f0 )/h;
224 unsigned int NDim()
const {
228 unsigned int NPar()
const {
232 double ParameterDerivative(
const double *x,
const double *p,
int ipar)
const {
234 std::copy(p, p+fN, fVec.begin());
235 double f0 = fFunc(x, p);
236 return DoParameterDerivative(x,p,f0,ipar);
240 void ParameterGradient(
const double * x,
const double * p,
double f0,
double * g) {
242 std::copy(p, p+fN, fVec.begin());
243 for (
unsigned int k = 0; k < fN; ++k) {
244 g[k] = DoParameterDerivative(x,p,f0,k);
249 void Gradient(
const double * x,
const double * p,
double f0,
double * g) {
251 std::copy(x, x+fN, fVec.begin());
252 for (
unsigned int k = 0; k < fN; ++k) {
254 double h = std::max( fEps* std::abs(x0), 8.0*fPrecision*(std::abs(x0) + fPrecision) );
258 double f1 = fFunc( &fVec.front(), p );
261 double f2 = fFunc( &fVec.front(), p );
262 g[k] = 0.5 * ( f2 -
f1 )/h;
265 g[k] = ( f1 - f0 )/h;
278 mutable std::vector<double> fVec;
285 if (rval > - std::numeric_limits<double>::max() && rval < std::numeric_limits<double>::max() )
289 return -std::numeric_limits<double>::max();
292 return + std::numeric_limits<double>::max();
295 if (rval > - std::numeric_limits<double>::max() && rval < std::numeric_limits<double>::max() )
299 rval = -std::numeric_limits<double>::max();
304 rval = + std::numeric_limits<double>::max();
313 template <
class GFunc>
315 const double *
x1,
const double *
x2,
const double * p,
double *g) {
318 ParamDerivFunc<GFunc> pfunc( gfunc);
319 IntegralEvaluator<ParamDerivFunc<GFunc> > igDerEval( pfunc, p,
true);
321 unsigned int npar = gfunc.NPar();
322 for (
unsigned int k = 0; k < npar; ++k ) {
323 pfunc.SetDerivComponent(k);
324 g[k] = igDerEval( x1, x2 );
344 unsigned int n = data.
Size();
349 #ifdef USE_PARAMCACHE 363 std::cout <<
"\n\nFit data size = " << n << std::endl;
364 std::cout <<
"evaluate chi2 using function " << &func <<
" " << p << std::endl;
365 std::cout <<
"use empty bins " << fitOpt.
fUseEmpty << std::endl;
366 std::cout <<
"use integral " << fitOpt.
fIntegral << std::endl;
367 std::cout <<
"use all error=1 " << fitOpt.
fErrors1 << std::endl;
370 #ifdef USE_PARAMCACHE 371 IntegralEvaluator<> igEval( func, 0, useBinIntegral);
373 IntegralEvaluator<> igEval( func, p, useBinIntegral);
375 double maxResValue = std::numeric_limits<double>::max() /
n;
376 double wrefVolume = 1.0;
377 std::vector<double> xc;
380 xc.resize(data.
NDim() );
384 for (
unsigned int i = 0; i <
n; ++ i) {
386 double y = 0, invError = 1.;
389 const double *
x1 = data.
GetPoint(i,y, invError);
393 double binVolume = 1.0;
395 unsigned int ndim = data.
NDim();
397 for (
unsigned int j = 0; j < ndim; ++j) {
398 binVolume *= std::abs( x2[j]-x1[j] );
399 xc[j] = 0.5*(x2[j]+ x1[j]);
402 binVolume *= wrefVolume;
405 const double *
x = (useBinVolume) ? &xc.front() :
x1;
407 if (!useBinIntegral) {
408 #ifdef USE_PARAMCACHE 411 fval =
func ( x, p );
420 if (useBinVolume) fval *= binVolume;
426 double invWeight = y * invError * invError;
429 double invError2 = (fval > 0) ? invWeight / fval : 0.0;
435 std::cout << x[0] <<
" " << y <<
" " << 1./invError <<
" params : ";
436 for (
unsigned int ipar = 0; ipar < func.
NPar(); ++ipar)
437 std::cout << p[ipar] <<
"\t";
438 std::cout <<
"\tfval = " << fval <<
" bin volume " << binVolume <<
" ref " << wrefVolume << std::endl;
446 double tmp = ( y -fval )* invError;
447 double resval = tmp * tmp;
451 if ( resval < maxResValue )
464 std::cout <<
"chi2 = " << chi2 <<
" n = " << nPoints << std::endl;
480 unsigned int n = data.
Size();
483 std::cout <<
"\n\nFit data size = " << n << std::endl;
484 std::cout <<
"evaluate effective chi2 using function " << &func <<
" " << p << std::endl;
495 unsigned int ndim = func.
NDim();
500 double maxResValue = std::numeric_limits<double>::max() /
n;
504 for (
unsigned int i = 0; i <
n; ++ i) {
510 double fval =
func( x, p );
512 double delta_y_func = y - fval;
516 const double *
ex = 0;
520 double eylow, eyhigh = 0;
522 if ( delta_y_func < 0)
530 while ( j < ndim && ex[j] == 0.) { j++; }
537 double kPrecision = 1.E-8;
538 for (
unsigned int icoord = 0; icoord < ndim; ++icoord) {
540 if (ex[icoord] > 0) {
544 double x0= x[icoord];
545 double h = std::max( kEps* std::abs(ex[icoord]), 8.0*kPrecision*(std::abs(x0) + kPrecision) );
546 double deriv = derivator.
Derivative1(f1D, x[icoord], h);
547 double edx = ex[icoord] * deriv;
550 std::cout <<
"error for coord " << icoord <<
" = " << ex[icoord] <<
" deriv " << deriv << std::endl;
555 double w2 = (e2 > 0) ? 1.0/e2 : 0;
556 double resval = w2 * ( y - fval ) * ( y - fval);
559 std::cout << x[0] <<
" " << y <<
" ex " << ex[0] <<
" ey " << ey <<
" params : ";
560 for (
unsigned int ipar = 0; ipar < func.
NPar(); ++ipar)
561 std::cout << p[ipar] <<
"\t";
562 std::cout <<
"\tfval = " << fval <<
"\tresval = " << resval << std::endl;
567 if ( resval < maxResValue )
580 std::cout <<
"chi2 = " << chi2 <<
" n = " << nPoints << std::endl;
597 MATH_ERROR_MSG(
"FitUtil::EvaluateChi2Residual",
"Error on the coordinates are not used in calculating Chi2 residual");
604 double y, invError = 0;
611 const double *
x1 = data.
GetPoint(i,y, invError);
613 IntegralEvaluator<> igEval( func, p, useBinIntegral);
615 unsigned int ndim = data.
NDim();
616 double binVolume = 1.0;
617 const double *
x2 = 0;
618 if (useBinVolume || useBinIntegral) x2 = data.
BinUpEdge(i);
623 xc =
new double[ndim];
624 for (
unsigned int j = 0; j < ndim; ++j) {
625 binVolume *= std::abs( x2[j]-x1[j] );
626 xc[j] = 0.5*(x2[j]+ x1[j]);
632 const double *
x = (useBinVolume) ? xc : x1;
634 if (!useBinIntegral) {
635 fval =
func ( x, p );
640 fval = igEval( x1, x2) ;
643 if (useBinVolume) fval *= binVolume;
649 double invWeight = y * invError * invError;
652 double invError2 = (fval > 0) ? invWeight / fval : 0.0;
657 double resval = ( y -fval )* invError;
665 unsigned int npar = func.
NPar();
670 if (!useBinIntegral ) {
679 SimpleGradientCalculator gc( npar, func);
680 if (!useBinIntegral )
681 gc.ParameterGradient(x, p, fval, g);
688 for (
unsigned int k = 0; k < npar; ++k) {
690 if (useBinVolume) g[k] *= binVolume;
694 if (useBinVolume)
delete [] xc;
708 MATH_ERROR_MSG(
"FitUtil::EvaluateChi2Residual",
"Error on the coordinates are not used in calculating Chi2 gradient");
return;
711 unsigned int nRejected = 0;
717 unsigned int n = data.
Size();
721 std::cout <<
"\n\nFit data size = " << n << std::endl;
722 std::cout <<
"evaluate chi2 using function gradient " << &func <<
" " << p << std::endl;
729 double wrefVolume = 1.0;
730 std::vector<double> xc;
733 xc.resize(data.
NDim() );
736 IntegralEvaluator<> igEval( func, p, useBinIntegral);
741 unsigned int npar = func.
NPar();
743 std::vector<double> gradFunc( npar );
745 std::vector<double> g( npar);
747 for (
unsigned int i = 0; i <
n; ++ i) {
750 double y, invError = 0;
751 const double *
x1 = data.
GetPoint(i,y, invError);
754 const double *
x2 = 0;
756 double binVolume = 1;
758 unsigned int ndim = data.
NDim();
760 for (
unsigned int j = 0; j < ndim; ++j) {
761 binVolume *= std::abs( x2[j]-x1[j] );
762 xc[j] = 0.5*(x2[j]+ x1[j]);
765 binVolume *= wrefVolume;
768 const double *
x = (useBinVolume) ? &xc.front() :
x1;
770 if (!useBinIntegral ) {
771 fval =
func ( x, p );
778 fval = igEval( x1, x2 ) ;
781 if (useBinVolume) fval *= binVolume;
784 std::cout << x[0] <<
" " << y <<
" " << 1./invError <<
" params : ";
785 for (
unsigned int ipar = 0; ipar < npar; ++ipar)
786 std::cout << p[ipar] <<
"\t";
787 std::cout <<
"\tfval = " << fval << std::endl;
795 unsigned int ipar = 0;
796 for ( ; ipar < npar ; ++ipar) {
799 if (useBinVolume) gradFunc[ipar] *= binVolume;
803 double dfval = gradFunc[ipar];
809 double tmp = - 2.0 * ( y -fval )* invError * invError * gradFunc[ipar];
825 if (nRejected != 0) {
826 assert(nRejected <= n);
827 nPoints = n - nRejected;
828 if (nPoints < npar)
MATH_ERROR_MSG(
"FitUtil::EvaluateChi2Gradient",
"Error - too many points rejected for overflow in gradient calculation");
832 std::copy(g.begin(), g.end(), grad);
853 const double *
x = data.
Coords(i);
854 double fval =
func ( x, p );
857 if (g == 0)
return logPdf;
869 SimpleGradientCalculator gc(func.
NPar(),
func);
870 gc.ParameterGradient(x, p, fval, g );
873 for (
unsigned int ipar = 0; ipar < func.
NPar(); ++ipar) {
878 std::cout << x[i] <<
"\t";
879 std::cout <<
"\tpar = [ " << func.
NPar() <<
" ] = ";
880 for (
unsigned int ipar = 0; ipar < func.
NPar(); ++ipar)
881 std::cout << p[ipar] <<
"\t";
882 std::cout <<
"\tfval = " << fval;
883 std::cout <<
"\tgrad = [ ";
884 for (
unsigned int ipar = 0; ipar < func.
NPar(); ++ipar)
885 std::cout << g[ipar] <<
"\t";
886 std::cout <<
" ] " << std::endl;
894 int iWeight,
bool extended,
unsigned int &nPoints) {
897 unsigned int n = data.
Size();
900 std::cout <<
"\n\nFit data size = " << n << std::endl;
901 std::cout <<
"func pointer is " <<
typeid(
func).
name() << std::endl;
908 #ifdef USE_PARAMCACHE 913 bool normalizeFunc =
false;
917 std::vector<double>
xmin(data.
NDim());
918 std::vector<double>
xmax(data.
NDim());
919 IntegralEvaluator<> igEval( func, p,
true);
921 norm = igEval.Integral(&
xmin[0],&
xmax[0]);
928 for (
unsigned int i = 0; i <
n; ++ i) {
929 const double *
x = data.
Coords(i);
930 #ifdef USE_PARAMCACHE 931 double fval =
func ( x );
933 double fval =
func ( x, p );
935 if (normalizeFunc) fval = fval /
norm;
938 std::cout <<
"x [ " << data.
NDim() <<
" ] = ";
939 for (
unsigned int j = 0; j < data.
NDim(); ++j)
940 std::cout << x[j] <<
"\t";
941 std::cout <<
"\tpar = [ " << func.
NPar() <<
" ] = ";
942 for (
unsigned int ipar = 0; ipar < func.
NPar(); ++ipar)
943 std::cout << p[ipar] <<
"\t";
944 std::cout <<
"\tfval = " << fval << std::endl;
949 double weight = data.
Weight(i);
956 sumW2 += weight*weight;
965 double extendedTerm = 0;
969 if (!normalizeFunc) {
970 IntegralEvaluator<> igEval( func, p,
true);
971 std::vector<double>
xmin(data.
NDim());
972 std::vector<double>
xmax(data.
NDim());
974 nuTot = igEval.Integral( &
xmin[0], &
xmax[0]);
978 extendedTerm = - nuTot;
982 extendedTerm = - (sumW2 / sumW) * nuTot;
991 logl += extendedTerm;
997 std::cout <<
"fit is extended n = " << n <<
" nutot " << nuTot <<
" extended LL term = " << extendedTerm <<
" logl = " << logl
1012 std::cout <<
"Logl = " << logl <<
" np = " << nPoints << std::endl;
1025 unsigned int n = data.
Size();
1028 unsigned int npar = func.
NPar();
1029 std::vector<double> gradFunc( npar );
1030 std::vector<double> g( npar);
1032 for (
unsigned int i = 0; i <
n; ++ i) {
1033 const double *
x = data.
Coords(i);
1034 double fval =
func ( x , p);
1036 for (
unsigned int kpar = 0; kpar < npar; ++ kpar) {
1038 g[kpar] -= 1./fval * gradFunc[ kpar ];
1039 else if (gradFunc [ kpar] != 0) {
1040 const double kdmax1 =
std::sqrt( std::numeric_limits<double>::max() );
1041 const double kdmax2 = std::numeric_limits<double>::max() / (4*
n);
1042 double gg = kdmax1 * gradFunc[ kpar ];
1043 if ( gg > 0) gg = std::min( gg, kdmax2);
1044 else gg = std::max(gg, - kdmax2);
1051 std::copy(g.begin(), g.end(), grad);
1068 IntegralEvaluator<> igEval( func, p, useBinIntegral);
1070 const double *
x2 = 0;
1072 double binVolume = 1;
1073 std::vector<double> xc;
1075 unsigned int ndim = data.
NDim();
1078 for (
unsigned int j = 0; j < ndim; ++j) {
1079 binVolume *= std::abs( x2[j]-x1[j] );
1080 xc[j] = 0.5*(x2[j]+ x1[j]);
1086 const double *
x = (useBinVolume) ? &xc.front() :
x1;
1088 if (!useBinIntegral ) {
1089 fval =
func ( x, p );
1094 fval = igEval( x1, x2 ) ;
1096 if (useBinVolume) fval *= binVolume;
1099 fval = std::max(fval, 0.0);
1100 double logPdf = - fval;
1110 if (g == 0)
return logPdf;
1112 unsigned int npar = func.
NPar();
1118 if (!useBinIntegral )
1127 SimpleGradientCalculator gc(func.
NPar(),
func);
1128 if (!useBinIntegral )
1129 gc.ParameterGradient(x, p, fval, g);
1136 for (
unsigned int k = 0; k < npar; ++k) {
1138 if (useBinVolume) g[k] *= binVolume;
1142 g[k] *= ( y/fval - 1.) ;
1144 const double kdmax1 =
std::sqrt( std::numeric_limits<double>::max() );
1153 std::cout <<
"x = " << x[0] <<
" logPdf = " << logPdf <<
" grad";
1154 for (
unsigned int ipar = 0; ipar < npar; ++ipar)
1155 std::cout << g[ipar] <<
"\t";
1156 std::cout << std::endl;
1164 const double * p,
int iWeight,
bool extended,
unsigned int & nPoints ) {
1182 unsigned int n = data.
Size();
1184 #ifdef USE_PARAMCACHE 1188 double nloglike = 0;
1196 bool useW2 = (iWeight == 2);
1199 double wrefVolume = 1.0;
1200 std::vector<double> xc;
1203 xc.resize(data.
NDim() );
1207 std::cout <<
"Evaluate PoissonLogL for params = [ ";
1208 for (
unsigned int j=0; j < func.
NPar(); ++j) std::cout << p[j] <<
" , ";
1209 std::cout <<
"] - data size = " << n <<
" useBinIntegral " << useBinIntegral <<
" useBinVolume " 1210 << useBinVolume <<
" useW2 " << useW2 <<
" wrefVolume = " << wrefVolume << std::endl;
1213 #ifdef USE_PARAMCACHE 1214 IntegralEvaluator<> igEval( func, 0, useBinIntegral);
1216 IntegralEvaluator<> igEval( func, p, useBinIntegral);
1223 for (
unsigned int i = 0; i <
n; ++ i) {
1224 const double *
x1 = data.
Coords(i);
1225 double y = data.
Value(i);
1228 double binVolume = 1.0;
1231 unsigned int ndim = data.
NDim();
1233 for (
unsigned int j = 0; j < ndim; ++j) {
1234 binVolume *= std::abs( x2[j]-x1[j] );
1235 xc[j] = 0.5*(x2[j]+ x1[j]);
1238 binVolume *= wrefVolume;
1241 const double *
x = (useBinVolume) ? &xc.front() :
x1;
1243 if (!useBinIntegral) {
1244 #ifdef USE_PARAMCACHE 1247 fval =
func ( x, p );
1255 if (useBinVolume) fval *= binVolume;
1261 if (i%NSAMPLE == 0) {
1262 std::cout <<
"evt " << i <<
" x1 = [ ";
1263 for (
unsigned int j=0; j < func.
NDim(); ++j) std::cout << x[j] <<
" , ";
1266 std::cout <<
"x2 = [ ";
1267 for (
unsigned int j=0; j < func.
NDim(); ++j) std::cout << data.
BinUpEdge(i)[j] <<
" , ";
1270 std::cout <<
" y = " << y <<
" fval = " << fval << std::endl;
1277 fval = std::max(fval, 0.0);
1288 double error = data.
Error(i);
1289 double weight = (error*error)/y;
1291 tmp = fval * weight;
1309 if (extended) tmp = fval -
y ;
1338 std::cout <<
"Loglikelihood = " << nloglike << std::endl;
1351 unsigned int n = data.
Size();
1357 double wrefVolume = 1.0;
1358 std::vector<double> xc;
1361 xc.resize(data.
NDim() );
1364 IntegralEvaluator<> igEval( func, p, useBinIntegral);
1366 unsigned int npar = func.
NPar();
1367 std::vector<double> gradFunc( npar );
1368 std::vector<double> g( npar);
1370 for (
unsigned int i = 0; i <
n; ++ i) {
1371 const double *
x1 = data.
Coords(i);
1372 double y = data.
Value(i);
1374 const double *
x2 = 0;
1376 double binVolume = 1.0;
1379 unsigned int ndim = data.
NDim();
1380 for (
unsigned int j = 0; j < ndim; ++j) {
1381 binVolume *= std::abs( x2[j]-x1[j] );
1382 xc[j] = 0.5*(x2[j]+ x1[j]);
1385 binVolume *= wrefVolume;
1388 const double *
x = (useBinVolume) ? &xc.front() :
x1;
1390 if (!useBinIntegral) {
1391 fval =
func ( x, p );
1398 fval = igEval( x1, x2) ;
1401 if (useBinVolume) fval *= binVolume;
1404 for (
unsigned int kpar = 0; kpar < npar; ++ kpar) {
1407 if (useBinVolume) gradFunc[kpar] *= binVolume;
1411 g[kpar] += gradFunc[ kpar ] * ( 1. - y/fval );
1412 else if (gradFunc [ kpar] != 0) {
1413 const double kdmax1 =
std::sqrt( std::numeric_limits<double>::max() );
1414 const double kdmax2 = std::numeric_limits<double>::max() / (4*
n);
1415 double gg = kdmax1 * gradFunc[ kpar ];
1416 if ( gg > 0) gg = std::min( gg, kdmax2);
1417 else gg = std::max(gg, - kdmax2);
1423 std::copy(g.begin(), g.end(), grad);
unsigned int Size() const
return number of fit points
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.
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
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
Class describing the unbinned data sets (just x coordinates values) of any dimensions.
double SumOfError2() const
compute the total sum of the error square (sum of weight square in case of a weighted data set) ...
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.
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.
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)
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...
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 ...
virtual unsigned int NPar() const =0
Return the number of Parameters.
double Weight(unsigned int ipoint) const
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.
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.
const double * Coords(unsigned int ipoint) const
return a pointer to the coordinates data for the given fit point
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)
const double * Coords(unsigned int ipoint) const
return pointer to coordinate data
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)
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)
void GetRange(unsigned int icoord, double &xmin, double &xmax) const
get the first range for given coordinate.
double Value(unsigned int ipoint) const
return the value for the given fit point
double SumOfContent() const
compute the total sum of the data content (sum of weights in cse of weighted data set) ...
unsigned int NDim() const
return coordinate data dimension
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)
const DataRange & Range() const
access to range
Documentation for the abstract class IBaseFunctionMultiDim.
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 ...
unsigned int Size() const
return number of contained points
User class for calculating the derivatives of a function.