How to use the distribution fitting calculator
- Enter your data — one column of numbers. Type them, paste them from Excel or as a list (12, 15, 18), or drag an .xlsx / .csv file onto the table. To see how it works first, press Example (measurements) or Example – counts.
- Data type and Possible values decide which distributions are tried. If you are not sure, leave “Not sure”: the calculator then tries every distribution your values allow.
- Press Calculate. Each table lists the distributions that were tried, best first (lowest AIC). In every column the best value is dark green, and a p-value below α is red.
- More options: rounding, excluding outliers, the histogram bins, how pasted values are split, and which distributions to compare.
Which distributions does the calculator check?
Common distributions are fitted to your data and compared. Which of them are tried depends on your data (see “Choosing Data type and Possible values” below).
Checked against
| Type | Distribution | Real-life cases |
|---|---|---|
| Measurement (continuous) | Normal | Heights, test scores, measurement errors: anything made of many small independent effects added together. |
| Student t | Like the normal, but far values come more often: daily stock-market returns, measurements with an occasional large error. | |
| Logistic | Like the normal with slightly longer tails: how much better one chess player plays than another in a game (the model behind Elo ratings), the dose at which patients start to respond to a drug. | |
| Laplace | A sharp peak in the middle and longer tails than the normal: day-to-day changes in a price or an exchange rate, forecast errors. | |
| Cauchy | Very long tails, so extreme values are common: the ratio of two independent normal measurements that both centre on 0, the shape of spectral lines in physics. | |
| Gumbel | The largest value of a group: the highest flood or the strongest wind gust of each year, the hottest day of each summer. For the smallest value of a group (the coldest day), multiply your data by −1 first. | |
| Lognormal | Quantities that grow by percentages, so a few are very large: incomes, house prices, city sizes, file sizes. | |
| Gamma | Waiting time until several events have happened, or the size of a total: rainfall per storm, insurance claim amounts. | |
| Chi-square distribution | The sum of squares of independent standard-normal values: a sample variance scaled by (n − 1) ÷ the true variance (for normal data). It is a gamma distribution with its rate fixed at ½, so it has one number (df) instead of two. The Gamma row always fits at least as closely, because it can take any rate, ½ included. The chi-square can still come first in the table when your data happen to sit on its scale, because AIC charges the gamma for its extra number. The Example's waiting times do: in minutes their gamma rate is 0.48, almost ½. In seconds the chi-square would fit them very badly. So a chi-square at the top usually means “a gamma with rate about ½”, not that your values are sums of squares. | |
| Weibull | Lifetimes and time to failure: light bulbs, machine parts, how long patients survive; also wind speeds. | |
| Exponential | Time between random events: minutes between phone calls, between customers arriving at a shop. | |
| Half-normal | Values of 0 and above, most of them near 0 and fewer the further out: the size of a measurement error when its sign is ignored (an error of −0.3 counts as 0.3), how far each bottle's fill is from the target amount, over or under, when the machine is set right. It is the normal curve with mean 0 folded at 0, with one number (sigma). | |
| Inverse Gaussian | Right-skewed positive values such as reaction times, repair times, and the time a quantity that drifts towards a limit, with random ups and downs, needs to reach it (a stock price reaching a target). | |
| Pareto | A few very large values and many small ones (a power law): wealth, city sizes or file sizes above some size, the largest insurance claims. Its lower limit is your smallest value. | |
| Beta | Shares and rates between 0 and 1: conversion rate of a web page, share of a budget, pass rate of a school. | |
| Uniform | Every value equally likely between a lowest and a highest: random numbers, the wait for a bus that comes every 10 minutes, rounding errors. | |
| Count (discrete) | Poisson | Events per hour, day or area when they happen at random: emails per hour, accidents per week, typing mistakes per page. |
| Zero-inflated Poisson | Counts with more zeros than a Poisson allows, because some cases can never have an event: doctor visits (many people never go), claims per policy, defects per unit. pstr0 is the share of cases that can never have an event. | |
| Negative binomial | Counts that vary more than a Poisson allows because some people or places have many more than others: doctor visits per year, insurance claims per driver. | |
| Geometric | Failures before the first success: unsuccessful sales calls before the first sale, tails before the first head. | |
| Binomial | Successes out of a fixed number of tries: defective items in a box of 20, patients (out of 30) who respond to a treatment, correct answers in a 10-question quiz. |
Common distributions that are not checked
Left out on purpose. The last column says why.
| Type | Distribution | Reason it isn't checked |
|---|---|---|
| Measurement (continuous) | F | It describes a ratio of two variances, the number an F test works with. Raw measurements almost never follow it. |
| Rayleigh | It is a Weibull distribution with shape = 2, so the Weibull row already covers it: for Rayleigh data the Weibull row shows a shape near 2. | |
| Triangular | Defined by a lowest, a highest and a most likely value. It is used for planning when you have no data (an expert's guess of how long a project takes), not as a model found from a sample. | |
| Three-parameter lognormal, Weibull, gamma | They add a third number, the lowest possible value. A sample cannot pin it down well, and you usually know it from what you measure (a price or a time cannot be below 0). If it is not 0, subtract it from your data and the ordinary versions apply. | |
| Count (discrete) | Hypergeometric | Successes in a sample taken without putting items back from a small population (aces in a 5-card hand). It needs the population size and its number of successes, which are known from the set-up, not estimated from the data. |
| Bernoulli | A binomial with one try (only 0 and 1). The Binomial row covers it: it shows size = 1. | |
| Multinomial | It splits counts among several categories (votes for 4 parties), so it needs a column for each category. This calculator fits one column of numbers; for categories use the Goodness of fit calculator. |
How the numbers in the table are found
Parameters — maximum likelihood
Each distribution has a few numbers, its parameters, that set its centre, spread and shape. The calculator picks the parameter values that make your data most likely. This is called maximum likelihood, and it is what R's fitdistrplus does too. The parameters keep R's names, so you can match them with R's output. One surprise: for the normal distribution, sd divides by n, not by n − 1, so it is a little smaller than the sample standard deviation S.
How L (the likelihood) is found
- For each of your values, take the height of the fitted distribution's curve at that value (its density). For counts, take the probability of that count.
- Multiply all of them together. The result is the likelihood L: how well this distribution, with these parameters, “expects” your data.
- For a large sample L is far too small, or too large, for a computer to hold, so we add logarithms instead: ln L = ln f(x1) + ln f(x2) + … + ln f(xn).
- Maximum likelihood tries parameter values until ln L is as large as possible.
AIC, ΔAIC and BIC
A distribution with more parameters can bend closer to the data, so a fair comparison adds a penalty for each parameter (k = the number of parameters):
- AIC = 2k − 2·ln L and BIC = k·ln(n) − 2·ln L. Lower is better.
- ΔAIC is how far a distribution is behind the best one. Under 2 means about as good; over 10 means clearly worse.
- Compare AIC only inside one table: a count distribution gives probabilities and a continuous one gives densities, so their AIC values are on different scales.
Chi-square, and the number of groups
- Sort the values and cut them into groups that hold about the same number of values. The number of groups is about (4n)2/5 (Vose's rule, the one R's fitdistrplus uses), and each group holds about n ÷ (4n)2/5 values. For n = 100 that is about 11 groups of 9 values.
- Expected count of a group = n × the probability the fitted distribution gives that group.
- χ2 = Σ (observed − expected)2 ÷ expected, added over the groups. Smaller is closer.
- Degrees of freedom: df = groups − 1 − parameters. The p-value comes from the chi-square distribution with that df. With df below 1 there is no p-value (“—”), and when some expected counts are below 5 the p-value is rough. It is approximate even then: the parameters come from the raw values, not from the groups, so the true p-value is somewhat larger than the one shown.
Anderson-Darling, Cramér-von Mises and Kolmogorov-Smirnov
Sort your values and draw their cumulative curve: at each value, the share of the data at or below it. It looks like a staircase. On the same picture, draw the fitted distribution's cumulative curve. The three tests measure the gap between the two curves in different ways:
- Kolmogorov-Smirnov (KS) — the single biggest gap.
- Cramér-von Mises (CvM) — the squared gaps at all your values, added up.
- Anderson-Darling (AD) — like CvM, but a gap in the far left or right (the tails) counts more.
Smaller is closer for all three. They are made for continuous data, so the counts table does not show them (R's fitdistrplus does not compute them for counts either).
The charts
Each chart box shows one distribution at a time, best first. Use the arrows, or swipe sideways, for the next one.
- Histogram — the grey bars are your data. The coloured bars are how many values the distribution expects in each bar: n × the chance it gives that bar. Its curve is scaled the same way (n × bar width × the density). Under the histograms, choose Bars and curve, Curve or Bars; More options → Histogram bins sets how the bars are cut.
- Q-Q plot — sort your values. The i-th smallest goes up, and the value the fitted distribution expects in that place (its quantile at (i − 0.5) ÷ n, as R's qqcomp) goes across. If the distribution fits, the dots lie on the dashed 45° line.
- Cumulative curves — the staircase of your data against the fitted curve. The red line is the largest gap between them: the Kolmogorov-Smirnov value.
Standard errors and confidence intervals
A standard error says how much an estimate would change from one sample to another. If ln L has a sharp top, a small change in the parameter lowers it a lot, so the estimate is precise. A flat top means a large standard error. The calculator measures how curved the top is (the second derivatives of ln L), as R's fitdist does. The 95% confidence interval is estimate ± 1.96 × standard error. The uniform distribution has none (its range is your smallest and largest values, not a smooth top), and neither do the binomial's size (a whole number), the Pareto's location (your smallest value), pstr0 when it is 0, a size of ∞ and the Student t's df when it stops at its limit. The Laplace uses a formula instead (see below). The note under the parameter table names the ones in your results.
Uniform and binomial — tried for every data set of their kind
Uniform: every value is equally likely between a lowest and a highest value (computer random numbers, or how long you wait for a bus that comes every 10 minutes, when you arrive at a random moment). Its fitted range runs exactly from your smallest to your largest value. That is why its Anderson-Darling value is always ∞: the test takes the logarithm of the cumulative curve at your smallest value, where that curve is exactly 0, and the logarithm of 0 is minus infinity. R gives Inf too.
Binomial: the number of successes out of a fixed number of tries, size, each with the same chance prob. Both are found from your data:
- size must be a whole number, at least as big as your largest count: you cannot have 7 successes out of 5 tries.
- For each possible size, the best prob is the mean ÷ size (a binomial's average is size × prob).
- Start at size = the largest count and keep adding 1 while ln L goes up. Where it stops rising is the answer.
- If ln L never stops rising, the counts spread at least as much as a Poisson (their variance is at least their mean). A binomial with a huge size and a tiny prob is a Poisson, so the table says “size = ∞ (same as Poisson)”.
Because both size and prob come from the data, AIC and BIC count 2 parameters. size is hard to pin down: on 50 values drawn with size = 12, the best size can come out as 16, because the likelihood changes little between nearby sizes.
Gumbel, inverse Gaussian, Pareto and zero-inflated Poisson — their parameters
- Gumbel: location is where the curve peaks, the most typical highest value; scale sets how spread out the highest values are. For the smallest value of a group, multiply your data by −1 first.
- Inverse Gaussian: mean is the average of your data; shape controls the spread: the bigger the shape, the less spread and the more bell-shaped the curve. The calculator uses shape = n ÷ Σ(1/x − 1/mean).
- Pareto: location is the lowest possible value, set to your smallest value; shape says how heavy the tail is: the smaller the shape, the more very large values. Because the range starts exactly at your smallest value, the Anderson-Darling value is always ∞ (as for the uniform) and the location has no standard error. It counts as a second parameter in AIC and BIC.
- Zero-inflated Poisson: with probability pstr0 a value is an extra zero; otherwise it is a Poisson count with mean lambda. If your data have no more zeros than a Poisson with the same mean expects, pstr0 is 0 and this row is the Poisson. A column of only 0s and 1s never has more zeros than that Poisson, so there pstr0 is always 0.
Laplace, chi-square and half-normal — their parameters
- Laplace: location is the median, the centre of the sharp peak; scale is the average distance of your values from it, so the bigger the scale, the wider and flatter the curve. With an even number of values, any location between the two middle values fits equally well; the calculator shows their midpoint. The curve has a sharp corner at the location, so the curvature method for standard errors does not apply: both standard errors use the large-sample value, scale ÷ √n. With a small sample the location's real uncertainty is somewhat larger.
- Chi-square distribution: df (degrees of freedom) is its mean, and its variance is 2·df. It is a gamma distribution with shape = df ÷ 2 and rate = ½, so it has one number, and df is not forced to be a whole number. Because the rate is fixed, it fits only data already on that scale; if your data are in other units it will fit badly while the Gamma row fits well.
- Half-normal: sigma is the spread of the normal curve before it is folded at 0. The calculator uses sigma = √(mean of x2). Zeros are allowed.
Is the best fit the true distribution?
Not necessarily. When many distributions are tried, one of them can fit well just by luck — the same problem as running many tests at once (multiple comparisons). Small samples make it worse, because several distributions then fit about equally well. Treat the best fit as a good candidate, not as proof: check that its ΔAIC lead is real, and prefer a distribution that matches how the data were made. For example, waiting times are often gamma or Weibull, sizes that grow by percentages are often lognormal, and rare events counted per hour are often Poisson.
Choosing Data type and Possible values
- Whole numbers are not always counts. Measurements rounded to whole units (age in years, weight in kg) are whole numbers too. If you are not sure, “Not sure – try both” fits both kinds, in two separate tables.
- Zeros. Lognormal, gamma, chi-square, Weibull, inverse Gaussian and Pareto need values above 0. With zeros in the data they are not fitted; exponential and half-normal, which allow 0, still are.
- All values below 0 (a loss written as −250, a depth below sea level): the calculator multiplies them by −1, so the positive-only distributions can be tried, and says so above the results. Everything is then reported for −x. This happens when Possible values is “Not sure” or “Only positive or only negative”; with “Any value” the data are fitted as they are.
- Between 0 and 1 (shares and rates): the beta distribution is made for this range. Values of exactly 0 or 1 cannot be fitted by it.
References
- Delignette-Muller, M. L. and Dutang, C. (2015). fitdistrplus: An R Package for Fitting Distributions. Journal of Statistical Software, 64(4), 1–34. doi:10.18637/jss.v064.i04 — the fitting method, the comparison statistics and the R code.
- Stephens, M. A. (1986). Tests based on EDF statistics. In D'Agostino, R. B. and Stephens, M. A. (eds.), Goodness-of-Fit Techniques, pp. 97–193. New York: Marcel Dekker. — the Anderson-Darling, Cramér-von Mises and Kolmogorov-Smirnov statistics.
- Vose, D. (2000). Risk Analysis: A Quantitative Guide (2nd ed.). Chichester: Wiley. — the number of chi-square groups, about (4n)2/5.
- Burnham, K. P. and Anderson, D. R. (2002). Model Selection and Multimodel Inference: A Practical Information-Theoretic Approach (2nd ed.). New York: Springer. — AIC and ΔAIC (under 2: about as good; over 10: clearly worse).