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