Getting started

Fits and the related statistical methods play an important role in particle physics. In collider experiments, fits are used to disentangle signal and background events and to condense the raw data into simple quantities like total cross sections or asymmetries, which are digestible for the theory community. In the presence of a signal fits are used to estimate the experimental uncertainties and to prove that the observation is significant enough to claim a discovery. In the absence of a signal, fits can be used to constrain the parameter spaces of theoretical models that predict a signal by to combining as much experimental data as possible. If data from several experiments is combined to constrain a specific theoretical model one usually speaks of a global fit.

The comparison of theoretical predictions with experimental data is usually complicated by the presence of uncertainties, both on the theoretical and the experimental side. For example, the theoretical prediction for a measured quantity may depend on a poorly known parameter (parametric uncertainty) or be only valid within a certain approximation (theoretical systematic uncertainty). Experimental measurements can be affected by statistical fluctuations (statistical uncertainty) or by miscalibrations of the experimental apparatus (experimental systematic uncertainty). To draw meaningful conclusions about a theoretical model from experimental data all these sources of uncertainties must modelled correctly and included in the statistical analysis.

The myFitter package is a Python module which provides a convenient, object oriented framework for globals fits, the modelling of experimental and theoretical errors and the inference of statements about a model’s parameter space (hypothesis tests). All information about a model (parameters, observables, experimental and theoretical constraints, nuisance parameters etc.) is contained in a single python class defined by the user and methods for activating and de-activating individual parameters or constraints, fitting the model to data, computing p-values and plotting confidence regions are provided by the myFitter module. The framework ist taylored for non-linear regression models (the most common type of models encountered in global fits) but can be used for fitting arbitrary models. The main features are:

  • computation maximum likelihood estimates of model parameters,
  • handling of non-linear constraints on the parameter space,
  • computation of profile likelihoods,
  • visualisation of one and two-dimensional confidence regions (via matplotlib),
  • numerical computation of p-values in likelihood ratio tests by means of importance sampling (myFitter method),
  • parallelisation.


myFitter requires Python 2.7 and the following Python packages:

  • NumPy (version 1.8 or later),
  • SciPy (version 0.13 or later),
  • vegas (version 2.2.1 or later),
  • cloud (version 2.8.5 or later),
  • matplotlib (version 1.3 or later).

To install myFitter you should download the latest source tarball from It will be named myFitter-x.y.tar.gz where x.y is the version number. myFitter uses the setuptools build system. You can install myFitter in your home directory with the following commands:

tar -zxvf myFitter-x.y.tar.gz
cd myFitter-x.y
python install --user

To install myFitter system-wide just omit the --user option.


For a quick start you can look at the following example scripts:
shows you how to define your own model class. (See The Model class for details).
shows you how to fit a model. (See Fitting the model for details.)
shows you how to compute profile likelihoods. (See Profiling the likelihood for details.),,,
show you how to run toy simulations, fill histograms, and compute p-values numerically. (See Toy simulations for details.)

Running any of the examples requires the file to be present in the working directory.

Table Of Contents

Previous topic

myFitter documentation

Next topic

Statistical inference

This Page