← All notes

Statistical note

Maximum-likelihood distribution fitting

Maximum-likelihood distribution fitting: theory, interpretation, Python computation, and a scientific-imaging case study.

6 min read

A probability distribution specifies how probability is assigned across possible values. Its parameters determine location, spread, shape, or event rate.

Concept figure for Maximum-likelihood distribution fitting

Mathematical definition

The central quantity is

thetahat=argmaxthetasumlogf(xitheta).theta_hat=argmax_theta sum log f(x_i|theta).

This expression states what is being counted, averaged, ranked, or compared. Its scale and direction must be interpreted in the context of the data and sampling design.

Compute it in Python

import numpy as np
from scipy import stats
data = np.array([2.1, 2.5, 3.2, 4.0, 4.8])
result = stats.fit(stats.gamma, data, bounds={'a': (0.1, 10), 'loc': (0, 0), 'scale': (0.1, 10)})
print(result.params)

The function is scipy.stats.fit. Inspect its current signature and return object in the official documentation for the version installed in your environment.

Interpretation and cautions

Check support, parameterization, and independence before interpreting fitted probabilities. A mathematically convenient family is not evidence that the data-generating process follows it.

A numerical value is not self-interpreting. Compare it with a baseline, uncertainty interval, operational threshold, or competing model, and retain the underlying observations or confusion counts.

Scientific-imaging case study

Modeling estimating distribution parameters from observations can help describe microscopy measurements, but validate the fit by acquisition batch and biological replicate.

Split train, validation, and test data at the specimen or experimental level. Report variability across independent repeats so that the metric describes generalization rather than leakage.