Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
FumiliErrorUpdator.cxx
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
11#include "Minuit2/MnFcn.h"
12#include "Minuit2/MnStrategy.h"
17#include "Minuit2/MnMatrix.h"
20#include "Minuit2/MnPrint.h"
21
22#include <limits>
23
24namespace ROOT {
25
26namespace Minuit2 {
27
28MinimumError
30{
31 // dummy methods to suppress unused variable warnings
32 // this member function should never be called within
33 // the Fumili method...
34 s0.Fval();
35 p1.Fval();
36 g1.IsValid();
37 return MinimumError(2);
38}
39
41 const GradientCalculator &gc, double lambda) const
42{
43 // calculate the error matrix using approximation of Fumili
44 // use only first derivatives (see tutorial par. 5.1,5.2)
45 // The Fumili Hessian is provided by the FumiliGradientCalculator class
46 // we apply also the Marquard lambda factor to increase weight of diagonal term
47 // as suggester in Numerical Receipt for Marquard method
48
49 // need to downcast to FumiliGradientCalculator
51 assert(fgc != nullptr);
52
53 MnPrint print("FumiliErrorUpdator");
54
55 // get Hessian from Gradient calculator
56
57 MnAlgebraicSymMatrix h = fgc->GetHessian();
58
59 int nvar = p1.Vec().size();
60
61 // apply Marquard lambda factor
62 double eps = 8 * std::numeric_limits<double>::min();
63 for (int j = 0; j < nvar; j++) {
64 h(j, j) *= (1. + lambda);
65 // if h(j,j) is zero what to do ?
66 if (std::fabs(h(j, j)) < eps) { // should use DBL_MIN
67 // put a cut off to avoid zero on diagonals
68 if (lambda > 1)
69 h(j, j) = lambda * eps;
70 else
71 h(j, j) = eps;
72 }
73 }
74
75 int ifail = Invert(h);
76 if (ifail != 0) {
77 print.Warn("inversion fails; return diagonal matrix");
78
79 for (unsigned int i = 0; i < h.Nrow(); i++) {
80 h(i, i) = 1. / h(i, i);
81 }
82 }
83
84 const MnAlgebraicSymMatrix &v0 = s0.Error().InvHessian();
85
86 // calculate by how much did the covariance matrix changed
87 // (if it changed a lot since the last step, probably we
88 // are not yet near the Minimum)
89 double dcov = 0.5 * (s0.Error().Dcovar() + sum_of_elements(h - v0) / sum_of_elements(h));
90
91 return MinimumError(h, dcov);
92}
93
94} // namespace Minuit2
95
96} // namespace ROOT
#define s0(x)
Definition RSha256.hxx:90
#define h(i)
Definition RSha256.hxx:106
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void gc
virtual MinimumError Update(const MinimumState &fMinimumState, const MinimumParameters &fMinimumParameters, const GradientCalculator &fGradientCalculator, double lambda) const
Member function that calculates the Error matrix (or the Hessian matrix containing the (approximate) ...
Fumili gradient calculator using external gradient provided by FCN Note that the computed Hessian and...
interface class for gradient calculators
Class describing a symmetric matrix of size n.
Definition MnMatrix.h:438
MinimumError keeps the inv.
MinimumState keeps the information (position, Gradient, 2nd deriv, etc) after one minimization step (...
void Warn(const Ts &... args)
Definition MnPrint.h:121
int Invert(LASymMatrix &)
Definition MnMatrix.cxx:207
double sum_of_elements(const LASymMatrix &)
Definition MnMatrix.cxx:98
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...