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
52
53 /**
54
55 Sets the model function for the data (for example gaussian+linear for a peak)
56
57 @param modelFCN a reference to the model function.
58
59 */
60
61 void SetModelFunction(const ParametricFunction &modelFCN) { fModelFunction = &modelFCN; }
62
63 /**
64
65 Returns the model function used for the data.
66
67 @return Returns a pointer to the model function.
68
69 */
70
72
73 /**
74
75 Evaluates the model function for the different measurement points and
76 the Parameter values supplied, calculates a figure-of-merit for each
77 measurement and returns a vector containing the result of this
78 evaluation.
79
80 @param par vector of Parameter values to feed to the model function.
81
82 @return A vector containing the figures-of-merit for the model function evaluated
83 for each set of measurements.
84
85 */
86
87 virtual std::vector<double> Elements(const std::vector<double> &par) const = 0;
88
89 /**
90
91 Accessor to the parameters of a given measurement. For example in the
92 case of a chi-square fit with a one-dimensional Gaussian, the Parameter
93 characterizing the measurement will be the position. It is the Parameter
94 that is feeded to the model function.
95
96 @param Index Index of the measueremnt the parameters of which to return
97 @return A vector containing the values characterizing a measurement
98
99 */
100
101 virtual const std::vector<double> &GetMeasurement(int Index) const = 0;
102
103 /**
104
105 Accessor to the number of measurements used for calculating the
106 present figure of merit.
107
108 @return the number of measurements
109
110 */
111
112 virtual int GetNumberOfMeasurements() const = 0;
113
114 /**
115
116 Calculates the function for the maximum likelihood method. The user must
117 implement in a class which inherits from FumiliChi2FCN the member function
118 Elements() which will supply the Elements for the sum.
119
120
121 @param par vector containing the Parameter values for the model function
122
123 @return The sum of the natural logarithm of the Elements multiplied by -1
124
125 @see FumiliFCNBase#elements
126
127 */
128
129 double operator()(const std::vector<double> &par) const
130 {
131
132 double sumoflogs = 0.0;
133 std::vector<double> vecElements = Elements(par);
134 unsigned int vecElementsSize = vecElements.size();
135
136 for (unsigned int i = 0; i < vecElementsSize; ++i) {
137 double tmp = vecElements[i];
138 // for max likelihood probability have to be positive
139 assert(tmp >= 0);
140 sumoflogs -= ROOT::Math::Util::EvalLog(tmp);
141 // std::cout << " i " << tmp << " lik " << sumoflogs << std::endl;
142 }
143
144 return sumoflogs;
145 }
146
147 /**
148
149 !!!!!!!!!!!! to be commented
150
151 */
152
153 virtual double Up() const { return 0.5; }
154
155private:
156 // A pointer to the model function which describes the data
158};
159
160} // namespace Minuit2
161
162} // namespace ROOT
163
164#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.
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.
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...