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.
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 a tiny number, 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.
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 does the binomial's size (a whole number).
Uniform and binomial — always checked
Uniform: every value is equally likely between a lowest and a highest value (computer random numbers, or the minute a bus arrives when it comes every 10 minutes). 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, n, each with the same chance p. Both are found from your data:
- n 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 n, the best p is the mean ÷ n (a binomial's average is n·p).
- Start at n = 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 n and a tiny p is a Poisson, so the table says “size = ∞ (same as Poisson)”.
Because both n and p come from the data, AIC and BIC count 2 parameters. n is hard to pin down: on 50 values drawn with n = 12, the best n can come out as 16, because the likelihood changes little between nearby values of n.
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 and Weibull need values above 0. With zeros in the data they are not fitted; exponential, which allows 0, still is.
- 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.
- 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.
- Stephens, M. A. (1986). Tests based on EDF statistics. In D'Agostino, R. B. and Stephens, M. A. (eds.), Goodness-of-Fit Techniques. Marcel Dekker.
- Vose, D. (2000). Risk Analysis: A Quantitative Guide. Wiley.
- Burnham, K. P. and Anderson, D. R. (2002). Model Selection and Multimodel Inference. Springer.