Commit 19065d9a authored by Thomas Vincent's avatar Thomas Vincent

add gaussian to util module

parent 936fbbde
......@@ -56,3 +56,19 @@ def bin_centers_to_range_step(centers):
min_, max_ = numpy.min(centers), numpy.max(centers)
step = (max_ - min_) / nbins
return min_ - step/2., max_ + step/2., step
_SQRT_2_PI = numpy.sqrt(2 * numpy.pi)
def gaussian(x, area, center, sigma):
"""Returns (a / (sqrt(2 * pi) * s)) * exp(- 0.5 * ((x - c) / s)^2)
:param numpy.ndarray x: values for which the gaussian must be computed
:param float area: area under curve ( amplitude * s * sqrt(2 * pi) )
:param float center:
:param float sigma:
:rtype: numpy.ndarray
"""
return ((area / (_SQRT_2_PI * sigma)) *
numpy.exp(-0.5 * ((x - center) / sigma) ** 2))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment