amep.functions.gaussian#

amep.functions.gaussian(x: ndarray, mu: float = 0.0, sig: float = 1.0, offset: float = 0.0, A: float = 1.0, normalized: bool = False) ndarray#

Gaussian Bell curve.

Equivalent to the probability density function of a normal distribution. By the central limit theorem this is a good guess for most peak shapes that arise from many random processes. The function is given by

\[g(x)=A\exp\left(-\frac{\left(x-\mu\right)^2}{\sigma^2}\right)+b.\]
Parameters:
  • x (np.ndarray) – \(x\) values.

  • mu (float) – Mean value \(\mu\).

  • sig (float) – Standard deviation \(\sigma\).

  • offset (float, optional) – Shifts the Gaussian by \(b\) in y direction. The default is 0.0.

  • A (float, optional) – Amplitude \(A\). The default is 1.0.

  • normalized (bool, optional) – If True, the Gaussian is normalized to unit area. The default is False.

Returns:

g(x)

Return type:

np.ndarray

Examples

>>> import amep
>>> import numpy as np
>>> x = np.linspace(-10, 10, 200)
>>> y = amep.functions.gaussian(x, mu=0.0, sig=1.0)
>>> fig, axs = amep.plot.new()
>>> axs.plot(x,y)
>>> axs.set_xlabel(r"$x$")
>>> axs.set_ylabel(r"$f(x)$")
>>> fig.savefig("./figures/functions/functions-gaussian-function.png")
../_images/functions-gaussian-function.png