A tool to fit data to many distributions and get the best one(s)

fit, distribution, fitting, scipy, python, statistics
pip install fitter==1.6.0


FITTER documentation

https://github.com/cokelaer/fitter/actions/workflows/main.yml/badge.svg?branch=main https://coveralls.io/repos/cokelaer/fitter/badge.png?branch=main Documentation Status

Compatible with Python 3.7, and 3.8, 3.9

What is it ?

The fitter package is a Python library used for fitting probability distributions to data. It provides a straightforward and and intuitive interface to estimate parameters for various types of distributions, both continuous and discrete. Using fitter, you can easily fit a range of distributions to your data and compare their fit, aiding in the selection of the most suitable distribution. The package is designed to be user-friendly and requires minimal setup, making it a useful tool for data scientists and statisticians working with probability distributions.


pip install fitter

fitter is also available on conda (bioconda channel):

conda install fitter



A standalone application (very simple) is also provided and works with input CSV files:

fitter fitdist data.csv --column-number 1 --distributions gamma,normal

It creates a file called fitter.png and a log fitter.log

From Python shell

First, let us create a data samples with N = 10,000 points from a gamma distribution:

from scipy import stats
data = stats.gamma.rvs(2, loc=1.5, scale=2, size=10000)


the fitting is slow so keep the size value to reasonable value.

Now, without any knowledge about the distribution or its parameter, what is the distribution that fits the data best ? Scipy has 80 distributions and the Fitter class will scan all of them, call the fit function for you, ignoring those that fail or run forever and finally give you a summary of the best distributions in the sense of sum of the square errors. The best is to give an example:

from fitter import Fitter
f = Fitter(data)
# may take some time since by default, all distributions are tried
# but you call manually provide a smaller set of distributions

See the online documentation for details.


Setting up and maintaining Fitter has been possible thanks to users and contributors. Thanks to all:



Version Description
  • for developers: uses pyproject.toml instead of setup.py
  • Fix progress bar fixing #74
  • Fix BIC formula #77
  • PR #74 to fix logger
  • fixed regression putting back joblib
  • removed easydev and replaced by tqdm for progress bar
  • progressbar from tqdm also allows replacement of joblib need
  • Update timeout in docs from 10 to 30 seconds by @mpadge in #47
  • Add Kolmogorov-Smirnov goodness-of-fit statistic by @lahdjirayhan in #58
  • switch branch from master to main
  • get_best function now returns the parameters as a dictionary of parameter names and their values rather than just a list of values (#23) thanks to contributor @kabirmdasraful
  • Accepting PR to fix progress bar issue reported in #37
  • parallel process implemented #25 thanks to @arsenyinfo
  • remove vervose arguments in Fitter class. Using the logging module instead
  • the Fitter.fit has now a progress bar
  • add a standalone application called … fitter (see the doc)
1.2.2 was not released
1.2.1 adding new class called histfit (see documentation)
  • Fixed the version. Previous version switched from 1.0.9 to 1.1.11. To start a fresh version, we increase to 1.2.0
  • Merged pull request required by bioconda
  • Merged pull request related to implementation of AIC/BIC/KL criteria (#19). This also fixes #9
  • Implement two functions to get all distributions, or a list of common distributions to help users decreading computational time (#20). Also added a FAQS section.
  • travis tested Python 3.6 and 3.7 (not 3.5 anymore)
  • Fixed deprecated warning
  • fitter is now in readthedocs at fitter.readthedocs.io
  • summary() now returns the dataframe (instead of printing it)
1.0.5 https://github.com/cokelaer/fitter/issues
1.0.2 add manifest to fix missing source in the pypi repository.