Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
Fit Tutorials

These tutorials illustrate the main fitting features. Their names are related to the aspect which is treated in the code.

In the tables below the tutorials are grouped according to what is fitted, e.g histograms and graphs, and the dimensionality. In addition, the tables include a column with the fit funcions used in the tutorials (e.g gaus, expo or user defined functions), and how they are combined (e.g sum or convolution).

Explore the examples below or go to the Fitting user guide. A list of all the Fit tutorials can be found here.

Table of contents

Histograms 1D

Tutorial Description Fit functions
fit1.C Simple fitting example (1-d histogram with an interpreted function). user defined
fit1.py Fit example.
myfit.C Get in memory an histogram from a root file and fit a user defined function. user defined
vectorizedFit.C Tutorial for creating a Vectorized TF1 function using a formula expression and use it for fitting an histogram. gaus
ErrorIntegral.C Estimate the error in the integral of a fitted function taking into account the errors in the parameters resulting from the fit. user defined
TestBinomial.C Perform a fit to a set of data with binomial errors like those derived from the division of two histograms. user defined
ConfidenceIntervals.C Illustrates TVirtualFitter::GetConfidenceIntervals. This method computes confidence intervals for the fitted function. linear, gaus, user defined
minuit2GausFit.C Perform fits with different configurations using Minuit2. gaus
fitcont.C Example illustrating how to draw the n-sigma contour of a Minuit fit. gaus
combinedFit.C combinedFit.py Combined (simultaneous) fit of two histogram with separate functions and some common parameters. expo + gaus
fitNormSum.C fitNormSum.py Tutorial for normalized sum of two functions Here: a background exponential and a crystalball function. expo + crystalball
FittingDemo.C Example for fitting signal/background. quadratic + Lorenzian
fithist.C Example of fit where the model is histogram + function. histogram + function
fitExclude.C Illustrates how to fit excluding points in a given range. mulitple linear
multifit.C multifit.py Fitting multiple functions to different ranges of a 1-D histogram. multiple gaus
fitConvolution.C fitConvolution.py Tutorial for convolution of two functions. expo * gaus
langaus.C Convoluted Landau and Gaussian Fitting Function (using ROOT's Landau and Gauss functions). Langdau * gaus
minuit2FitBench.C Demonstrate performance and usage of Minuit2 and Fumili2 for monodimensional fits. Langdau * gaus

Histograms 2D

Tutorial Description Fit functions
fit2.C Fitting a 2-D histogram. user defined
fit2a.C Fitting a 2-D histogram (a variant). user defined
fit2d.C Example illustrating how to fit a 2-d histogram of type y=f(x). pol1
TwoHistoFit2D.C Example to fit two histograms at the same time. user defined
fit2dHist.C Example to fit two histograms at the same time via the Fitter class. user defined
fitslicesy.C Illustrates how to use the TH1::FitSlicesY function. It uses the TH2F histogram generated in macro hsimple.C
minuit2FitBench2D.C Minuit2 fit 2D benchmark. gaus

Graphs 1D

Tutorial Description Fit functions
fitLinear.C Example of fitting with a linear function, using TLinearFitter. This example is for a TGraphErrors, but it can also be used when fitting a histogram, a TGraph2D or a TMultiGraph. user defined
fitLinearRobust.C This tutorial shows how the least trimmed squares regression, included in the TLinearFitter class, can be used for fitting in cases when the data contains outliers. qubic
fitMultiGraph.C Fitting a parabola to a multigraph of 3 partly overlapping graphs with different errors. quadratic
ConfidenceIntervals.C Illustrates TVirtualFitter::GetConfidenceIntervals. This method computes confidence intervals for the fitted function. linear, gaus, user defined

Graphs 2D

Tutorial Description Fit functions
graph2dfit.C Fitting a TGraph2D. user defined
line3Dfit.C Fitting of a TGraph2D with a 3D straight line. linear
fitCircle.C Generate points distributed with some errors around a circle. Fit a circle through the points and draw. circle
ConfidenceIntervals.C Illustrates TVirtualFitter::GetConfidenceIntervals. This method computes confidence intervals for the fitted function. linear, gaus, user defined

Higher dimensional histograms and graphs

Tutorial Description Fit functions
exampleFit3D.C Example of fitting a 3D function. Typical multidimensional parametric regression where the predictor depends on 3 variables. user defined
fitLinear2.C Fit a 5d hyperplane by n points, using the linear fitter directly. linear
multidimfit.C Multi-Dimensional Parametrisation and Fitting. user defined
Ifit.C Example of a program to fit non-equidistant data points. user defined

Files

file  combinedFit.C
  View in nbviewer Open in SWAN
Combined (simultaneous) fit of two histogram with separate functions and some common parameters
 
file  combinedFit.py
  View in nbviewer Open in SWAN
Combined (simultaneous) fit of two histogram with separate functions and some common parameters
 
file  ConfidenceIntervals.C
  View in nbviewer Open in SWAN
Illustrates TVirtualFitter::GetConfidenceIntervals This method computes confidence intervals for the fitted function
 
file  ErrorIntegral.C
  View in nbviewer Open in SWAN
Estimate the error in the integral of a fitted function taking into account the errors in the parameters resulting from the fit.
 
file  exampleFit3D.C
  View in nbviewer Open in SWAN
example of fitting a 3D function Typical multidimensional parametric regression where the predictor depends on 3 variables
 
file  fit1.C
  View in nbviewer Open in SWAN
Simple fitting example (1-d histogram with an interpreted function)
 
file  fit1.py
  View in nbviewer Open in SWAN
Fit example.
 
file  fit2.C
  View in nbviewer Open in SWAN
Fitting a 2-D histogram This tutorial illustrates :
 
file  fit2a.C
  View in nbviewer Open in SWAN
Fitting a 2-D histogram (a variant) This tutorial illustrates :
 
file  fit2d.C
  View in nbviewer Open in SWAN
Example illustrating how to fit a 2-d histogram of type y=f(x)
 
file  fit2dHist.C
  View in nbviewer Open in SWAN
Example to fit two histograms at the same time via the Fitter class.
 
file  fitCircle.C
  View in nbviewer Open in SWAN
Generate points distributed with some errors around a circle Fit a circle through the points and draw To run the script, do, eg
 
file  fitcont.C
  View in nbviewer Open in SWAN
Example illustrating how to draw the n-sigma contour of a Minuit fit.
 
file  fitConvolution.C
  View in nbviewer Open in SWAN
Tutorial for convolution of two functions
 
file  fitConvolution.py
  View in nbviewer Open in SWAN
Tutorial for convolution of two functions
 
file  fitExclude.C
  View in nbviewer Open in SWAN
Illustrates how to fit excluding points in a given range.
 
file  fithist.C
  View in nbviewer Open in SWAN
Example of fit where the model is histogram + function
 
file  fitLinear.C
  View in nbviewer Open in SWAN
Example of fitting with a linear function, using TLinearFitter This example is for a TGraphErrors, but it can also be used when fitting a histogram, a TGraph2D or a TMultiGraph
 
file  fitLinear2.C
  View in nbviewer Open in SWAN
Fit a 5d hyperplane by n points, using the linear fitter directly
 
file  fitLinearRobust.C
  View in nbviewer Open in SWAN
This tutorial shows how the least trimmed squares regression, included in the TLinearFitter class, can be used for fitting in cases when the data contains outliers.
 
file  fitMultiGraph.C
  View in nbviewer Open in SWAN
fitting a parabola to a multigraph of 3 partly overlapping graphs with different errors
 
file  fitNormSum.C
  View in nbviewer Open in SWAN
Tutorial for normalized sum of two functions Here: a background exponential and a crystalball function Parameters can be set:
 
file  fitNormSum.py
  View in nbviewer Open in SWAN
Tutorial for normalized sum of two functions Here: a background exponential and a crystalball function Parameters can be set:
 
file  fitpanel_playback.C
 This file will test all the transient frames (aka Dialog windows) displayed in the fitpanel, as the rest of the functionality is tried automatically with the UnitTest.C unit.
 
file  fitslicesy.C
  View in nbviewer Open in SWAN
Illustrates how to use the TH1::FitSlicesY function It uses the TH2F histogram generated in macro hsimple.C It invokes FitSlicesY and draw the fitted "mean" and "sigma" in 2 sepate pads.
 
file  FittingDemo.C
  View in nbviewer Open in SWAN
Example for fitting signal/background.
 
file  graph2dfit.C
  View in nbviewer Open in SWAN
Fitting a TGraph2D
 
file  Ifit.C
  View in nbviewer Open in SWAN
Example of a program to fit non-equidistant data points
 
file  langaus.C
  View in nbviewer Open in SWAN
Convoluted Landau and Gaussian Fitting Function (using ROOT's Landau and Gauss functions)
 
file  line3Dfit.C
  View in nbviewer Open in SWAN
Fitting of a TGraph2D with a 3D straight line
 
file  minuit2FitBench.C
  View in nbviewer Open in SWAN
Demonstrate performance and usage of Minuit2 and Fumili2 for monodimensional fits.
 
file  minuit2FitBench2D.C
  View in nbviewer Open in SWAN
Minuit2 fit 2D benchmark.
 
file  minuit2GausFit.C
  View in nbviewer Open in SWAN
Perform fits with different configurations using Minuit2
 
file  multidimfit.C
  View in nbviewer Open in SWAN
Multi-Dimensional Parametrisation and Fitting
 
file  multifit.C
  View in nbviewer Open in SWAN
Fitting multiple functions to different ranges of a 1-D histogram Example showing how to fit in a sub-range of an histogram A histogram is created and filled with the bin contents and errors defined in the table below.
 
file  multifit.py
  View in nbviewer Open in SWAN
Fitting multiple functions to different ranges of a 1-D histogram Example showing how to fit in a sub-range of an histogram A histogram is created and filled with the bin contents and errors defined in the table below.
 
file  myfit.C
  View in nbviewer Open in SWAN
Get in memory an histogram from a root file and fit a user defined function.
 
file  TestBinomial.C
  View in nbviewer Open in SWAN
Perform a fit to a set of data with binomial errors like those derived from the division of two histograms.
 
file  TwoHistoFit2D.C
  View in nbviewer Open in SWAN
Example to fit two histograms at the same time.
 
file  vectorizedFit.C
  View in nbviewer Open in SWAN
Tutorial for creating a Vectorized TF1 function using a formula expression and use it for fitting an histogram