← All Base Form Math projects
BM-27NOT STARTEDBASE FORM · PROBABILITYMATHPYTHON

Best-fit distribution finder

Load real waiting times or file sizes, fit candidate distributions by maximum likelihood, and pick the winner with error bars.

EST.6 h
REWARD+100 XP
AFTERoriginal

ML-ARENA BENCHMARKS

YOUR NUMBER VS THE INDUSTRY'S
METRICINDUSTRYMINE
fitted parameters and standard errors
GOAL · match within 1e-4
scipy.stats .fit—
no results yet
YOUR RESULTS

Your recorded results appear here.

Brief

Real data rarely comes labelled with its distribution. Waiting times might be exponential, gamma or Weibull. File sizes might be lognormal. In this project you fit each candidate to real data, put error bars on every parameter, and let the numbers pick a winner.

The fitting rule is maximum likelihood. Given data x1,…,xnx_1, \dots, x_n and a model with density f(x;θ)f(x; \theta), choose the θ\theta that maximises the log-likelihood ℓ(θ)=∑ilog⁡f(xi;θ)\ell(\theta) = \sum_i \log f(x_i; \theta). For the exponential with rate λ\lambda, ℓ(λ)=nlog⁡λ−λ∑ixi\ell(\lambda) = n \log \lambda - \lambda \sum_i x_i, which peaks at λ^=1/xˉ\hat\lambda = 1/\bar x. Gamma and Weibull have no such formula, so you climb the log-likelihood with the optimisers you already have.

The shape of the peak tells you how sure to be. A sharp peak means small error bars. The standard errors are approximately the square roots of the diagonal of (−∇2ℓ(θ^))−1\left(-\nabla^2 \ell(\hat\theta)\right)^{-1}, the inverse of the negative Hessian at the optimum. To compare models with different numbers of parameters, use AIC, which adds a penalty of 2 per parameter to −2ℓ(θ^)-2\ell(\hat\theta).

VISUALFig. 1
0.2 0.4 0.5 0.6 0.8 0 -2 -4 -6 rate λ log-likelihood minus its peak n = 20: SE 0.112 n = 200: SE 0.035 −0.5 ≈ ±1 SE
Log-likelihood around the best rate 0.5 for 20 and for 200 exponential samples. Ten times more data gives a peak about √10 ≈ 3.2 times narrower. Why it's here: Error bars come from curvature; this shows why before you compute a Hessian.
HINT · OBJECTIVE 2
Stuck? Hints stay hidden until you ask.
HINT · OBJECTIVE 4
Stuck? Hints stay hidden until you ask.

DATA · a public real-world dataset

Objectives

0 / 5 CLEARED

Read-only. Log in to update progress.

VICTORY CONDITIONS

  1. Fitted parameters for all four candidates match scipy.stats (expon, lognorm, gamma, weibull_min with floc=0) within 1e-4 relative. Record the worst gap with `python tools/mlarena.py record BM-27 "<max relative difference>"`.
  2. Your Hessian standard errors match λ̂/√n for the exponential to 1e-6, and agree with a 1,000-resample bootstrap within 10% for the others.
  3. The report names a winner by AIC, shows its QQ plot, and says where it still fits badly.

Side quests

Fit a mixture of two distributions with the EM algorithm and see whether it beats every single one.
Add a prior and compute the MAP estimate. Compare it with the MLE on a small subsample.
Show that average log-likelihood on held-out data is minus the cross-entropy, and estimate the KL gap between the winner and the runner-up.

Terms in plain words

Likelihood
The probability (or density) of the data you actually saw, viewed as a function of the model's parameters.
Maximum likelihood estimate (MLE)
The parameter values that make the observed data most probable. In practice you maximise the log-likelihood, which turns a product into a sum.
Fisher information
How sharply the log-likelihood curves around its peak. More information means a narrower peak and a more precise estimate.
Standard error
The typical error of an estimate. For an MLE it is approximately the square root of the diagonal of the inverse of the negative Hessian at the peak.
AIC
Akaike's information criterion, 2k − 2·(max log-likelihood) for a model with k parameters. Lower is better; the 2k term charges for extra parameters.