14 print(
"Failed to import numpy.")
26print(
"Use Functor1D for wrapping one-dimensional function and compute integral of f(x) = x^2-1")
31value = ig.Integral(0, 3)
32print(
"integral-1D value = ", value)
34if (
not ROOT.TMath.AreEqualRel(value, expValue, 1.E-15)) :
35 print(
"Error computing integral - computed value - different than expected, diff = ", value - expValue)
39print(
"\n\nUse Functor for wrapping a multi-dimensional function, the Rosenbrock Function r(x,y) and find its minimum")
41def RosenbrockFunction(xx):
46 return 100*tmp1*tmp1+tmp2*tmp2
55initialParams = np.array([0.,0.], dtype=
'd')
56fitter.FitFCN(func2D, initialParams)
57fitter.Result().
Print(ROOT.std.cout)
58if (
not ROOT.TMath.AreEqualRel(fitter.Result().
Parameter(0), 1, 1.E-3)
or not ROOT.TMath.AreEqualRel(fitter.Result().
Parameter(1), 1, 1.E-3)) :
59 print(
"Error minimizing Rosenbrock function ")
64print(
"\n\nUse GradFunctor1D for making a function object implementing f(x) and f'(x)")
71prevLevel = ROOT.gErrorIgnoreLevel
72ROOT.gErrorIgnoreLevel=ROOT.kFatal
73ret = ROOT.gSystem.Load(
"libMathMore")
74ROOT.gErrorIgnoreLevel=prevLevel
76 print(
"ROOT has not Mathmore")
77 print(
"derivative value at x = 1", gradFunc.Derivative(1) )
81 rf.SetFunction(gradFunc, 3)
84 print(
"Found root value x0 : f(x0) = 0 : ", value)
86 print(
"Error finding a ROOT of function f(x)=x^2-1")
89print(
"\n\nUse GradFunctor for making a function object implementing f(x,y) and df(x,y)/dx and df(x,y)/dy")
91def RosenbrockDerivatives(xx, icoord):
96 return 2*(200*x*x*x-200*x*y+x-1)
98 return 200 * (y - x * x)
104initialParams = array.array(
'd',[0.,0.])
105fitter.FitFCN(gradFunc2d, initialParams)
106fitter.Result().
Print(ROOT.std.cout)
107if (
not ROOT.TMath.AreEqualRel(fitter.Result().
Parameter(0), 1, 1.E-3)
or not ROOT.TMath.AreEqualRel(fitter.Result().
Parameter(1), 1, 1.E-3)) :
108 print(
"Error minimizing Rosenbrock function ")
void Print(GNN_Data &d, std::string txt="")
Fitter class, entry point for performing all type of fits.
Functor1D class for one-dimensional functions.
Documentation for class Functor class.
GradFunctor1D class for one-dimensional gradient functions.
GradFunctor class for Multidimensional gradient functions.
User Class for performing numerical integration of a function in one dimension.
User Class to find the Root of one dimensional functions.