Skip to content

Commit

Permalink
Add extended gaussian
Browse files Browse the repository at this point in the history
Just for convenience
  • Loading branch information
raymondEhlers committed Aug 20, 2019
1 parent 2277444 commit af69d29
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pachyderm/fit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
from .cost_function import ( # noqa: F401
BinnedChiSquared, BinnedLogLikelihood, ChiSquared, CostFunctionBase, LogLikelihood, SimultaneousFit
)
from .function import AddPDF, gaussian # noqa: F401
from .function import AddPDF, extended_gaussian, gaussian # noqa: F401
17 changes: 17 additions & 0 deletions pachyderm/fit/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,20 @@ def gaussian(x: Union[np.ndarray, float], mean: float, sigma: float) -> Union[np
Calculated gaussian value(s).
"""
return 1.0 / np.sqrt(2 * np.pi * np.square(sigma)) * np.exp(-1.0 / 2.0 * np.square((x - mean) / sigma))

def extended_gaussian(x: Union[np.ndarray, float], mean: float, sigma: float, amplitude: float) -> Union[np.ndarray, float]:
r""" Extended gaussian.
.. math::
f = A / \sqrt{2 * \pi * \sigma^{2}} * \exp{-\frac{(x - \mu)^{2}}{(2 * \sigma^{2}}}
Args:
x: Value(s) where the gaussian should be evaluated.
mean: Mean of the gaussian distribution.
sigma: Width of the gaussian distribution.
amplitude: Amplitude of the gaussian.
Returns:
Calculated gaussian value(s).
"""
return amplitude / np.sqrt(2 * np.pi * np.square(sigma)) * np.exp(-1.0 / 2.0 * np.square((x - mean) / sigma))

0 comments on commit af69d29

Please sign in to comment.