Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
FumiliMaximumLikelihoodFCN.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_FumiliMaximumLikelihoodFCN
11#define ROOT_Minuit2_FumiliMaximumLikelihoodFCN
12
13#include "FumiliFCNBase.h"
15#include "Math/Util.h"
16#include <vector>
17#include <cassert>
18
19namespace ROOT {
20
21namespace Minuit2 {
22
23/**
24
25Extension of the FCNBase for the Fumili method. Fumili applies only to
26minimization problems used for fitting. The method is based on a
27linearization of the model function negleting second derivatives.
28User needs to provide the model function. In this cased the function
29to be minimized is the sum of the logarithms of the model function
30for the different measurements times -1.
31
32
33@author Andras Zsenei and Lorenzo Moneta, Creation date: 3 Sep 2004
34
35@see <A HREF="http://www.cern.ch/winkler/minuit/tutorial/mntutorial.pdf">MINUIT Tutorial</A> on function minimization,
36section 5
37
38@see FumiliStandardMaximumLikelihoodFCN
39
40@ingroup Minuit
41
42\todo Insert a nice latex formula...
43
44*/
45
47
48public:
50
51 /**
52
53 Sets the model function for the data (for example gaussian+linear for a peak)
54
55 @param modelFCN a reference to the model function.
56
57 */
58
59 void SetModelFunction(const ParametricFunction &modelFCN) { fModelFunction = &modelFCN; }
60
61 /**
62
63 Returns the model function used for the data.
64
65 @return Returns a pointer to the model function.
66
67 */
68
70
71 /**
72
73 Evaluates the model function for the different measurement points and
74 the Parameter values supplied, calculates a figure-of-merit for each
75 measurement and returns a vector containing the result of this
76 evaluation.
77
78 @param par vector of Parameter values to feed to the model function.
79
80 @return A vector containing the figures-of-merit for the model function evaluated
81 for each set of measurements.
82
83 */
84
85 virtual std::vector<double> Elements(std::vector<double> const &par) const = 0;
86
87 /**
88
89 Accessor to the parameters of a given measurement. For example in the
90 case of a chi-square fit with a one-dimensional Gaussian, the Parameter
91 characterizing the measurement will be the position. It is the Parameter
92 that is passed to the model function.
93
94 @param Index Index of the measueremnt the parameters of which to return
95 @return A vector containing the values characterizing a measurement
96
97 */
98
99 virtual const std::vector<double> &GetMeasurement(int Index) const = 0;
100
101 /**
102
103 Accessor to the number of measurements used for calculating the
104 present figure of merit.
105
106 @return the number of measurements
107
108 */
109
110 virtual int GetNumberOfMeasurements() const = 0;
111
112 /**
113
114 Calculates the function for the maximum likelihood method. The user must
115 implement in a class which inherits from FumiliChi2FCN the member function
116 Elements() which will supply the Elements for the sum.
117
118
119 @param par vector containing the Parameter values for the model function
120
121 @return The sum of the natural logarithm of the Elements multiplied by -1
122
123 @see FumiliFCNBase#elements
124
125 */
126
127 double operator()(std::vector<double> const &par) const override
128 {
129
130 double sumoflogs = 0.0;
131 std::vector<double> vecElements = Elements(par);
132 unsigned int vecElementsSize = vecElements.size();
133
134 for (unsigned int i = 0; i < vecElementsSize; ++i) {
135 double tmp = vecElements[i];
136 // for max likelihood probability have to be positive
137 assert(tmp >= 0);
138 sumoflogs -= ROOT::Math::Util::EvalLog(tmp);
139 // std::cout << " i " << tmp << " likelihood " << sumoflogs << std::endl;
140 }
141
142 return sumoflogs;
143 }
144
145 /**
146
147 !!!!!!!!!!!! to be commented
148
149 */
150
151 double Up() const override { return 0.5; }
152
153private:
154 // A pointer to the model function which describes the data
156};
157
158} // namespace Minuit2
159
160} // namespace ROOT
161
162#endif // ROOT_Minuit2_FumiliMaximumLikelihoodFCN
Extension of the FCNBase for the Fumili method.
Extension of the FCNBase for the Fumili method.
void SetModelFunction(const ParametricFunction &modelFCN)
Sets the model function for the data (for example gaussian+linear for a peak)
const ParametricFunction * ModelFunction() const
Returns the model function used for the data.
double Up() const override
!!!!!!!!!!!! to be commented
double operator()(std::vector< double > const &par) const override
Calculates the function for the maximum likelihood method.
virtual std::vector< double > Elements(std::vector< double > const &par) const =0
Evaluates the model function for the different measurement points and the Parameter values supplied,...
virtual const std::vector< double > & GetMeasurement(int Index) const =0
Accessor to the parameters of a given measurement.
virtual int GetNumberOfMeasurements() const =0
Accessor to the number of measurements used for calculating the present figure of merit.
Function which has parameters.
T EvalLog(T x)
safe evaluation of log(x) with a protections against negative or zero argument to the log smooth line...
Definition Util.h:64
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...