Skip to content

Instantly share code, notes, and snippets.

View spiccinini's full-sized avatar

Santiago Piccinini spiccinini

View GitHub Profile
anonymous
anonymous / estimate-gaussian.py
Created February 7, 2018 03:22
"""Estimate parameters of a Gaussian from a histogram.
You typically get about 10% error with a sample size of 32 in 8 bins
that cover its range reasonably well. The errors look pretty Gaussian
with some weird rounding artifacts.
For 8 bins, this algorithm requires 16 multiplications, 8 additional
squarings, 28 additions, a subtraction, a threshold to zero, two divisions,
and a square root, about 50 numerical operations in all. But the operations
are easily vectorizable. Also they can be all executed in a single pass over