skg.gauss

Unnormalized Gaussian bell curve fit.

The amplitude of this function is one of the fitting parameters, unlike for the two-parameter PDF version.

f(x) = a e^{-\frac{1}{2} \left(\frac{x - \mu}{\sigma}\right)^2}

The third fitting parameter, a, is the amplitude of the Gaussian at x = \mu. This is equivalent, up to a scaling factor, to normalizing the area under the curve, as the PDF version does.

The conversion between amplitude a and normalization A is given in Three-Parameter Gaussian as

a = \frac{A}{\sigma \sqrt{2 \pi}}

For for the normalized (two parameter) Gaussian probability density function, see gauss_pdf. For the CDF, see gauss_cdf.

Todo

Add proper handling of colinear inputs (and other singular matrix cases).

Todo

Add tests.

Todo

Add nan_policy argument.

Todo

Add axis parameter. Figure out how to do it properly.

Todo

Add PEP8 check to formal tests.

Todo

Include amplitude in integrals.

Todo

Allow broadcasting of x and y, not necessarily identical size

Functions

gauss_fit(x, y[, sorted]) Gaussian bell curve fit of the form a e^{-\frac{1}{2}\left(\frac{x - \mu}{\sigma}\right)^2}.
model(x, a, mu, sigma) Compute y = a e^{-\frac{1}{2}\left(\frac{x - \mu}{\sigma}\right)^2}.
skg.gauss.gauss_fit(x, y, sorted=True)[source]

Gaussian bell curve fit of the form a e^{-\frac{1}{2}\left(\frac{x - \mu}{\sigma}\right)^2}.

This implementation is based on an extentsion the approximate solution to integral equation (3), presented in Régressions et équations intégrales and extended in Extended Applications.

Parameters:
  • x (array-like) – The x-values of the data points. The fit will be performed on a raveled version of this array.
  • y (array-like) – The y-values of the data points corresponding to x. Must be the same size as x. The fit will be performed on a raveled version of this array.
  • sorted (bool) – Set to True if x is already monotonically increasing or decreasing. If False, x will be sorted into increasing order, and y will be sorted along with it.
Returns:

a, mu, sigma – A three-element array containing the estimated amplitude, mean and standard deviation, in that order.

Return type:

ndarray

References

skg.gauss.model(x, a, mu, sigma)[source]

Compute y = a e^{-\frac{1}{2}\left(\frac{x - \mu}{\sigma}\right)^2}.

Parameters:
  • x (array-like) – The value of the model will be the same shape as the input.
  • a (float) – The amplitude at x = \mu.
  • mu (float) – The mean.
  • sigma (float) – The standard deviation.
Returns:

y – An array of the same shape as x, containing the model computed for the given parameters.

Return type:

array-like