erdogant/distfit

distfit is a python library for probability density fitting.

What it solves

When you have a dataset and want to understand its underlying probability distribution (e.g., to make predictions or detect anomalies), it is tedious to manually test many theoretical distributions. distfit automates this by testing many known distributions and ranking them by goodness-of-fit.

How it works

distfit tries to fit your data to a large library of theoretical distributions (over 90) using parametric methods. It scores each fit using goodness-of-fit statistics like RSS/SSE, Wasserstein, Kolmogorov-Smirnov, or Energy. It returns the best distribution along with its parameters (location, scale, shape). If you don't want to assume a specific distribution, it offers non-parametric methods (quantile and percentile). For discrete data, it uses the binomial distribution. For multiple columns, it can fit multivariate distributions using copula-based methods. Once fitted, you can compute probabilities for new data points, detect outliers, generate synthetic samples, and make plots.

Who it's for

Data scientists, statisticians, and analysts who need to characterize data distributions, detect outliers, or generate synthetic data. It is also useful for educational purposes and for anyone who wants to quickly find the best theoretical distribution for their empirical data without writing manual fitting code.

Highlights

  • Automatically tests over 90 theoretical distributions and returns the best fit with parameters.
  • Supports parametric, non-parametric (quantile/percentile), discrete (binomial), and multivariate (copula) fitting.
  • Includes goodness-of-fit scoring methods (RSS, Wasserstein, KS, Energy) to rank distributions.
  • Provides tools for prediction, outlier detection, synthetic data generation, and plotting.

Related

  • Project
  • Project
  • Project
  • Project