Logo ROOT  
Reference Guide
rf606_nllerrorhandling.C File Reference

Detailed Description

View in nbviewer Open in SWAN

Likelihood and minimization: understanding and customizing error handling in likelihood evaluations

RooFit v3.60 -- Developed by Wouter Verkerke and David Kirkby
Copyright (C) 2000-2013 NIKHEF, University of California & Stanford University
All rights reserved, please read http://roofit.sourceforge.net/license.txt
[#1] INFO:Minization -- RooMinimizer::optimizeConst: activating const optimization
**********
** 1 **SET PRINT 1
**********
**********
** 2 **SET NOGRAD
**********
PARAMETER DEFINITIONS:
NO. NAME VALUE STEP SIZE LIMITS
1 k -3.00000e+01 4.00000e+00 -5.00000e+01 -1.00000e+01
2 m0 5.29100e+00 4.50000e-03 5.20000e+00 5.30000e+00
**********
** 3 **SET ERR 0.5
**********
**********
** 4 **SET PRINT 1
**********
**********
** 5 **SET STR 1
**********
NOW USING STRATEGY 1: TRY TO BALANCE SPEED AGAINST RELIABILITY
**********
** 6 **MIGRAD 1000 1
**********
FIRST CALL TO USER FUNCTION AT NEW START POINT, WITH IFLAG=4.
START MIGRAD MINIMIZATION. STRATEGY 1. CONVERGENCE WHEN EDM .LT. 1.00e-03
FCN=-2417.48 FROM MIGRAD STATUS=INITIATE 6 CALLS 7 TOTAL
EDM= unknown STRATEGY= 1 NO ERROR MATRIX
EXT PARAMETER CURRENT GUESS STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 k -3.00000e+01 4.00000e+00 2.01358e-01 6.43007e+00
2 m0 5.29100e+00 4.50000e-03 1.62481e-01 6.64912e+01
ERR DEF= 0.5
RooMinimizerFcn: Minimized function has error status.
Returning maximum FCN so far (-2417.21) to force MIGRAD to back out of this region. Error log follows.
Parameter values: k=-33.8074 m0=5.29014
RooNLLVar::nll_argus_argusData[ paramSet=(k,m0) ]
function value is NAN @ paramSet=(k = -33.8074,m0 = 5.29014)
RooArgusBG::argus[ m=m m0=m0 c=k p=0.5 ]
getLogVal() top-level p.d.f evaluates to zero @ m=m=5.29019, m0=m0=5.29014, c=k=-33.8074, p=0.5=0.5
RooMinimizerFcn: Minimized function has error status.
Returning maximum FCN so far (-2417.21) to force MIGRAD to back out of this region. Error log follows.
Parameter values: k=-36.8169 m0=5.29
RooNLLVar::nll_argus_argusData[ paramSet=(k,m0) ]
function value is NAN @ paramSet=(k = -36.8169,m0 = 5.29)
RooArgusBG::argus[ m=m m0=m0 c=k p=0.5 ]
getLogVal() top-level p.d.f evaluates to zero @ m=m=5.29019, m0=m0=5.29, c=k=-36.8169, p=0.5=0.5
MIGRAD MINIMIZATION HAS CONVERGED.
MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX.
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=-2419.31 FROM MIGRAD STATUS=CONVERGED 53 CALLS 54 TOTAL
EDM=1.01098e-06 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 k -3.53645e+01 3.51933e+00 6.11933e-03 -3.22387e-03
2 m0 5.29040e+00 2.62052e-04 2.99558e-04 1.05016e-01
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF=0.5
1.253e+01 1.781e-04
1.781e-04 6.867e-08
PARAMETER CORRELATION COEFFICIENTS
NO. GLOBAL 1 2
1 0.19207 1.000 0.192
2 0.19207 0.192 1.000
**********
** 7 **SET ERR 0.5
**********
**********
** 8 **SET PRINT 1
**********
**********
** 9 **HESSE 1000
**********
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=-2419.31 FROM HESSE STATUS=OK 10 CALLS 64 TOTAL
EDM=1.01335e-06 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER INTERNAL INTERNAL
NO. NAME VALUE ERROR STEP SIZE VALUE
1 k -3.53645e+01 3.51934e+00 1.22387e-03 -2.71552e-01
2 m0 5.29040e+00 2.62139e-04 1.19823e-05 9.40803e-01
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF=0.5
1.253e+01 1.782e-04
1.782e-04 6.872e-08
PARAMETER CORRELATION COEFFICIENTS
NO. GLOBAL 1 2
1 0.19212 1.000 0.192
2 0.19212 0.192 1.000
[#1] INFO:Minization -- RooMinimizer::optimizeConst: deactivating const optimization
[#1] INFO:Minization -- RooMinimizer::optimizeConst: activating const optimization
**********
** 10 **SET PRINT 1
**********
**********
** 11 **SET NOGRAD
**********
PARAMETER DEFINITIONS:
NO. NAME VALUE STEP SIZE LIMITS
1 k -3.53645e+01 3.51934e+00 -5.00000e+01 -1.00000e+01
2 m0 5.29040e+00 1.00000e-01 5.20000e+00 5.30000e+00
MINUIT WARNING IN PARAMETR
============== VARIABLE2 BROUGHT BACK INSIDE LIMITS.
MINUIT WARNING IN PARAMETR
============== VARIABLE2 BROUGHT BACK INSIDE LIMITS.
**********
** 12 **SET ERR 0.5
**********
**********
** 13 **SET PRINT 1
**********
**********
** 14 **SET STR 1
**********
NOW USING STRATEGY 1: TRY TO BALANCE SPEED AGAINST RELIABILITY
**********
** 15 **MIGRAD 1000 1
**********
FIRST CALL TO USER FUNCTION AT NEW START POINT, WITH IFLAG=4.
START MIGRAD MINIMIZATION. STRATEGY 1. CONVERGENCE WHEN EDM .LT. 1.00e-03
RooMinimizerFcn: Minimized function has error status but is ignored.
Parameter values: k=-35.3645 m0=5.28878
RooNLLVar::nll_argus_argusData[ paramSet=(k,m0) ] has 1 errors
RooArgusBG::argus[ m=m m0=m0 c=k p=0.5 ] has 4 errors
FCN=-2419.31 FROM MIGRAD STATUS=INITIATE 8 CALLS 9 TOTAL
EDM= unknown STRATEGY= 1 NO ERROR MATRIX
EXT PARAMETER CURRENT GUESS STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 k -3.53645e+01 3.51934e+00 1.83942e-01 -3.06251e-03
2 m0 5.29040e+00 1.00000e-01 1.56884e+00 -3.10261e-02
ERR DEF= 0.5
MIGRAD MINIMIZATION HAS CONVERGED.
MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX.
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=-2419.31 FROM MIGRAD STATUS=CONVERGED 29 CALLS 30 TOTAL
EDM=9.95144e-07 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 k -3.53641e+01 3.51933e+00 6.12353e-03 -2.59546e-03
2 m0 5.29040e+00 2.62070e-04 2.96356e-04 1.09322e-01
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF=0.5
1.253e+01 1.782e-04
1.782e-04 6.868e-08
PARAMETER CORRELATION COEFFICIENTS
NO. GLOBAL 1 2
1 0.19209 1.000 0.192
2 0.19209 0.192 1.000
**********
** 16 **SET ERR 0.5
**********
**********
** 17 **SET PRINT 1
**********
**********
** 18 **HESSE 1000
**********
COVARIANCE MATRIX CALCULATED SUCCESSFULLY
FCN=-2419.31 FROM HESSE STATUS=OK 10 CALLS 40 TOTAL
EDM=9.96715e-07 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER INTERNAL INTERNAL
NO. NAME VALUE ERROR STEP SIZE VALUE
1 k -3.53641e+01 3.51933e+00 2.44941e-04 -2.71530e-01
2 m0 5.29040e+00 2.62154e-04 1.18542e-05 9.40803e-01
ERR DEF= 0.5
EXTERNAL ERROR MATRIX. NDIM= 25 NPAR= 2 ERR DEF=0.5
1.253e+01 1.783e-04
1.783e-04 6.873e-08
PARAMETER CORRELATION COEFFICIENTS
NO. GLOBAL 1 2
1 0.19212 1.000 0.192
2 0.19212 0.192 1.000
[#1] INFO:Minization -- RooMinimizer::optimizeConst: deactivating const optimization
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooArgusBG.h"
#include "RooNLLVar.h"
#include "TCanvas.h"
#include "TAxis.h"
#include "RooPlot.h"
using namespace RooFit;
void rf606_nllerrorhandling()
{
// C r e a t e m o d e l a n d d a t a s e t
// ----------------------------------------------
// Observable
RooRealVar m("m", "m", 5.20, 5.30);
// Parameters
RooRealVar m0("m0", "m0", 5.291, 5.20, 5.30);
RooRealVar k("k", "k", -30, -50, -10);
// Pdf
RooArgusBG argus("argus", "argus", m, m0, k);
// Sample 1000 events in m from argus
RooDataSet *data = argus.generate(m, 1000);
// P l o t m o d e l a n d d a t a
// --------------------------------------
RooPlot *frame1 = m.frame(Bins(40), Title("Argus model and data"));
data->plotOn(frame1);
argus.plotOn(frame1);
// F i t m o d e l t o d a t a
// ---------------------------------
// The ARGUS background shape has a sharp kinematic cutoff at m=m0
// and is prone to evaluation errors if the cutoff parameter m0
// is floated: when the pdf cutoff value is lower than that in data
// events with m>m0 will have zero probability
// Perform unbinned ML fit. Print detailed error messages for up to
// 10 events per likelihood evaluation. The default error handling strategy
// is to return a very high value of the likelihood to MINUIT if errors occur,
// which will force MINUIT to retreat from the problematic area
argus.fitTo(*data, PrintEvalErrors(10));
// Perform another fit. In this configuration only the number of errors per
// likelihood evaluation is shown, if it is greater than zero. The
// EvalErrorWall(kFALSE) arguments disables the default error handling strategy
// and will cause the actual (problematic) value of the likelihood to be passed
// to MINUIT.
//
// NB: Use of this option is NOT recommended as default strategy as broken -log(L) values
// can often be lower than 'good' ones because offending events are removed.
// This may effectively create a false minimum in problem areas. This is clearly
// illustrated in the second plot
m0.setError(0.1);
argus.fitTo(*data, PrintEvalErrors(0), EvalErrorWall(kFALSE));
// P l o t l i k e l i h o o d a s f u n c t i o n o f m 0
// ------------------------------------------------------------------
// Construct likelihood function of model and data
RooNLLVar nll("nll", "nll", argus, *data);
// Plot likelihood in m0 in range that includes problematic values
// In this configuration no messages are printed for likelihood evaluation errors,
// but if an likelihood value evaluates with error, the corresponding value
// on the curve will be set to the value given in EvalErrorValue().
RooPlot *frame2 = m0.frame(Range(5.288, 5.293), Title("-log(L) scan vs m0, problematic regions masked"));
frame2->SetMaximum(15);
frame2->SetMinimum(0);
TCanvas *c = new TCanvas("rf606_nllerrorhandling", "rf606_nllerrorhandling", 1200, 400);
c->Divide(2);
c->cd(1);
gPad->SetLeftMargin(0.15);
frame1->GetYaxis()->SetTitleOffset(1.4);
frame1->Draw();
c->cd(2);
gPad->SetLeftMargin(0.15);
frame2->GetYaxis()->SetTitleOffset(1.4);
frame2->Draw();
}
Date
07/2008
Author
Wouter Verkerke

Definition in file rf606_nllerrorhandling.C.

c
#define c(i)
Definition: RSha256.hxx:101
m
auto * m
Definition: textangle.C:8
RooFit::EvalErrorValue
RooCmdArg EvalErrorValue(Double_t value)
Definition: RooGlobalFunc.cxx:65
RooPlot::Draw
virtual void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
Definition: RooPlot.cxx:691
RooArgusBG.h
RooFit::Bins
RooCmdArg Bins(Int_t nbin)
Definition: RooGlobalFunc.cxx:174
RooFit::PrintEvalErrors
RooCmdArg PrintEvalErrors(Int_t numErrors)
Definition: RooGlobalFunc.cxx:205
RooAbsReal::getVal
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:91
RooFit::ShiftToZero
RooCmdArg ShiftToZero()
Definition: RooGlobalFunc.cxx:50
RooPlot::SetMaximum
virtual void SetMaximum(Double_t maximum=-1111)
Set maximum value of Y axis.
Definition: RooPlot.cxx:1081
TCanvas.h
RooDataSet.h
RooNLLVar.h
RooPlot::frame
static RooPlot * frame(const RooAbsRealLValue &var, Double_t xmin, Double_t xmax, Int_t nBins)
Create a new frame for a given variable in x.
Definition: RooPlot.cxx:249
RooFit
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition: RooCFunction1Binding.h:29
RooAbsData::plotOn
virtual RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Definition: RooAbsData.cxx:547
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
RooNLLVar
Class RooNLLVar implements a -log(likelihood) calculation from a dataset and a PDF.
Definition: RooNLLVar.h:27
RooPlot.h
RooPlot::GetYaxis
TAxis * GetYaxis() const
Definition: RooPlot.cxx:1258
RooPlot
A RooPlot is a plot frame and a container for graphics objects within that frame.
Definition: RooPlot.h:44
RooFit::EvalErrorWall
RooCmdArg EvalErrorWall(Bool_t flag)
Definition: RooGlobalFunc.cxx:206
RooRealVar.h
kRed
@ kRed
Definition: Rtypes.h:66
RooAbsReal::plotOn
virtual RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg(), const RooCmdArg &arg10=RooCmdArg()) const
Plot (project) PDF on specified frame.
Definition: RooAbsReal.cxx:1714
RooFit::LineColor
RooCmdArg LineColor(Color_t color)
Definition: RooGlobalFunc.cxx:56
TCanvas
The Canvas class.
Definition: TCanvas.h:23
TAxis.h
RooFit::Range
RooCmdArg Range(const char *rangeName, Bool_t adjustNorm=kTRUE)
Definition: RooGlobalFunc.cxx:52
RooArgusBG
RooArgusBG is a RooAbsPdf implementation describing the ARGUS background shape.
Definition: RooArgusBG.h:25
RooPlot::SetMinimum
virtual void SetMinimum(Double_t minimum=-1111)
Set minimum value of Y axis.
Definition: RooPlot.cxx:1091
gPad
#define gPad
Definition: TVirtualPad.h:287
RooDataSet
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:33
TAttAxis::SetTitleOffset
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title.
Definition: TAttAxis.cxx:293
RooRealVar
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:36
RooFit::Title
RooCmdArg Title(const char *name)
Definition: RooGlobalFunc.cxx:173