Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
FCNBase.h
Go to the documentation of this file.
1// @(#)root/minuit2:$Id$
2// Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2005 LCG ROOT Math team, CERN/PH-SFT *
7 * *
8 **********************************************************************/
9
10#ifndef ROOT_Minuit2_FCNBase
11#define ROOT_Minuit2_FCNBase
12
13#include "Minuit2/MnConfig.h"
14
16
17#include <ROOT/RSpan.hxx>
18
19#include <vector>
20
21namespace ROOT {
22
23namespace Minuit2 {
24
25/**
26
27 \defgroup Minuit Minuit2 Minimization Library
28
29 New Object-oriented implementation of the MINUIT minimization package.
30 More information is available at the home page of the \ref Minuit2Page "Minuit2" minimization package".
31
32 \ingroup Math
33*/
34
37};
38
39//______________________________________________________________________________
40/**
41
42
43Interface (abstract class) defining the function to be minimized, which has to be implemented by the user.
44
45@author Fred James and Matthias Winkler; modified by Andras Zsenei and Lorenzo Moneta
46
47\ingroup Minuit
48
49 */
50
51class FCNBase : public GenericFunction {
52
53public:
54
55 /**
56
57 The meaning of the vector of parameters is of course defined by the user,
58 who uses the values of those parameters to calculate their function Value.
59 The order and the position of these parameters is strictly the one specified
60 by the user when supplying the starting values for minimization. The starting
61 values must be specified by the user, either via an std::vector<double> or the
62 MnUserParameters supplied as input to the MINUIT minimizers such as
63 VariableMetricMinimizer or MnMigrad. Later values are determined by MINUIT
64 as it searches for the Minimum or performs whatever analysis is requested by
65 the user.
66
67 @param v function parameters as defined by the user.
68
69 @return the Value of the function.
70
71 @see MnUserParameters
72 @see VariableMetricMinimizer
73 @see MnMigrad
74
75 */
76
77 double operator()(std::vector<double> const &v) const override = 0;
78
79 /**
80
81 Error definition of the function. MINUIT defines Parameter errors as the
82 change in Parameter Value required to change the function Value by up. Normally,
83 for chisquared fits it is 1, and for negative log likelihood, its Value is 0.5.
84 If the user wants instead the 2-sigma errors for chisquared fits, it becomes 4,
85 as Chi2(x+n*sigma) = Chi2(x) + n*n.
86
87 Comment a little bit better with links!!!!!!!!!!!!!!!!!
88
89 */
90
91 virtual double ErrorDef() const { return Up(); }
92
93 /**
94
95 Error definition of the function. MINUIT defines Parameter errors as the
96 change in Parameter Value required to change the function Value by up. Normally,
97 for chisquared fits it is 1, and for negative log likelihood, its Value is 0.5.
98 If the user wants instead the 2-sigma errors for chisquared fits, it becomes 4,
99 as Chi2(x+n*sigma) = Chi2(x) + n*n.
100
101 \todo Comment a little bit better with links!!!!!!!!!!!!!!!!! Idem for ErrorDef()
102
103 */
104
105 virtual double Up() const = 0;
106
107 /**
108 add interface to set dynamically a new error definition
109 Re-implement this function if needed.
110 */
111 virtual void SetErrorDef(double){};
112
113 virtual bool HasGradient() const { return false; }
114
115 virtual std::vector<double> Gradient(std::vector<double> const&) const { return {}; }
116 virtual std::vector<double> GradientWithPrevResult(std::vector<double> const& parameters, double * /*previous_grad*/,
117 double * /*previous_g2*/, double * /*previous_gstep*/) const
118 {
119 return Gradient(parameters);
120 };
121
124 };
125
126 /// return second derivatives (diagonal of the Hessian matrix)
127 virtual std::vector<double> G2(std::vector<double> const&) const { return {};}
128
129 /// return Hessian
130 virtual std::vector<double> Hessian(std::vector<double> const&) const { return {};}
131
132 virtual bool HasHessian() const { return false; }
133
134 virtual bool HasG2() const { return false; }
135};
136
137} // namespace Minuit2
138
139} // namespace ROOT
140
141#endif // ROOT_Minuit2_FCNBase
Interface (abstract class) defining the function to be minimized, which has to be implemented by the ...
Definition FCNBase.h:51
virtual double Up() const =0
Error definition of the function.
double operator()(std::vector< double > const &v) const override=0
The meaning of the vector of parameters is of course defined by the user, who uses the values of thos...
virtual bool HasHessian() const
Definition FCNBase.h:132
virtual std::vector< double > GradientWithPrevResult(std::vector< double > const &parameters, double *, double *, double *) const
Definition FCNBase.h:116
virtual std::vector< double > G2(std::vector< double > const &) const
return second derivatives (diagonal of the Hessian matrix)
Definition FCNBase.h:127
virtual std::vector< double > Hessian(std::vector< double > const &) const
return Hessian
Definition FCNBase.h:130
virtual void SetErrorDef(double)
add interface to set dynamically a new error definition Re-implement this function if needed.
Definition FCNBase.h:111
virtual GradientParameterSpace gradParameterSpace() const
Definition FCNBase.h:122
virtual double ErrorDef() const
Error definition of the function.
Definition FCNBase.h:91
virtual std::vector< double > Gradient(std::vector< double > const &) const
Definition FCNBase.h:115
virtual bool HasG2() const
Definition FCNBase.h:134
virtual bool HasGradient() const
Definition FCNBase.h:113
Class from which all the other classes, representing functions, inherit.
GradientParameterSpace
Definition FCNBase.h:35
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...