# Gaussian function

(Redirected from Integral of a Gaussian function)

In mathematics, a Gaussian function, often simply referred to as a Gaussian, is a function of the form:

${\displaystyle f(x)=ae^{-(x-b)^{2}/(2c^{2})}}$

for arbitrary real constants a, b and non zero c. It is named after the mathematician Carl Friedrich Gauss. The graph of a Gaussian is a characteristic symmetric "bell curve" shape. The parameter a is the height of the curve's peak, b is the position of the center of the peak and c (the standard deviation, sometimes called the Gaussian RMS width) controls the width of the "bell".

Gaussian functions are often used to represent the probability density function of a normally distributed random variable with expected value μ = b and variance σ2 = c2. In this case, the Gaussian is of the form:

${\displaystyle g(x)={\frac {1}{\sigma {\sqrt {2\pi }}}}e^{-{\frac {1}{2}}\left((x-\mu )/\sigma \right)^{2}}.}$

Gaussian functions are widely used in statistics to describe the normal distributions, in signal processing to define Gaussian filters, in image processing where two-dimensional Gaussians are used for Gaussian blurs, and in mathematics to solve heat equations and diffusion equations and to define the Weierstrass transform.

## Properties

Gaussian functions arise by composing the exponential function with a concave quadratic function. The Gaussian functions are thus those functions whose logarithm is a concave quadratic function.

The parameter c is related to the full width at half maximum (FWHM) of the peak according to

${\displaystyle \mathrm {FWHM} =2{\sqrt {2\ln 2}}\ c\approx 2.35482c.}$[note 1]

The function may then be expressed in terms of the FWHM, represented by w:

${\displaystyle f(x)=ae^{-4(\ln 2)(x-b)^{2}/w^{2}}}$

Alternatively, the parameter c can be interpreted by saying that the two inflection points of the function occur at x = b − c and x = b + c.

The full width at tenth of maximum (FWTM) for a Gaussian could be of interest and is

${\displaystyle \mathrm {FWTM} =2{\sqrt {2\ln 10}}\ c\approx 4.29193c.}$

Gaussian functions are analytic, and their limit as x → ∞ is 0 (for the above case of b = 0).

Gaussian functions are among those functions that are elementary but lack elementary antiderivatives; the integral of the Gaussian function is the error function. Nonetheless their improper integrals over the whole real line can be evaluated exactly, using the Gaussian integral

${\displaystyle \int _{-\infty }^{\infty }e^{-x^{2}}\,dx={\sqrt {\pi }}}$

and one obtains

${\displaystyle \int _{-\infty }^{\infty }ae^{-(x-b)^{2}/(2c^{2})}\,dx=ac\cdot {\sqrt {2\pi }}.}$

This integral is 1 if and only if ${\displaystyle a={\tfrac {1}{c{\sqrt {2\pi }}}}}$, and in this case the Gaussian is the probability density function of a normally distributed random variable with expected value μ = b and variance σ2 = c2:

${\displaystyle g(x)={\frac {1}{\sigma {\sqrt {2\pi }}}}e^{-(1/2)\left((x-\mu )/\sigma \right)^{2}}.}$

These Gaussians are plotted in the accompanying figure.

Normalized Gaussian curves with expected value μ and variance σ2. The corresponding parameters are ${\displaystyle a={\tfrac {1}{\sigma {\sqrt {2\pi }}}}}$, b = μ and c = σ.

Gaussian functions centered at zero minimize the Fourier uncertainty principle.

The product of two Gaussian functions is a Gaussian, and the convolution of two Gaussian functions is also a Gaussian, with variance being the sum of the original variances: ${\displaystyle c^{2}=c_{1}^{2}+c_{2}^{2}}$. The product of two Gaussian probability density functions, though, is not in general a Gaussian PDF.

Taking the Fourier transform (unitary, angular frequency convention) of a Gaussian function with parameters a = 1, b = 0 and c yields another Gaussian function, with parameters ${\displaystyle c}$, b = 0 and ${\displaystyle {\frac {1}{c}}}$.[1] So in particular the Gaussian functions with b = 0 and ${\displaystyle c=1}$ are kept fixed by the Fourier transform (they are eigenfunctions of the Fourier transform with eigenvalue 1). A physical realization is that of the diffraction pattern: for example, a photographic slide whose transmittance has a Gaussian variation is also a Gaussian function.

The fact that the Gaussian function is an eigenfunction of the continuous Fourier transform allows us to derive the following interesting[clarification needed] identity from the Poisson summation formula:

${\displaystyle \sum _{k\in \mathbb {Z} }\exp \left(-\pi \cdot \left({\frac {k}{c}}\right)^{2}\right)=c\cdot \sum _{k\in \mathbb {Z} }\exp(-\pi \cdot (kc)^{2}).}$

## Integral of a Gaussian function

The integral of an arbitrary Gaussian function is

${\displaystyle \int _{-\infty }^{\infty }a\,e^{-\left(x-b\right)^{2}/2c^{2}}\,dx={\sqrt {2}}a\,\left\vert c\right\vert \,{\sqrt {\pi }}}$

An alternative form is

${\displaystyle \int _{-\infty }^{\infty }k\,e^{-fx^{2}+gx+h}\,dx=\int _{-\infty }^{\infty }k\,e^{-f\left(x-g/(2f)\right)^{2}+g^{2}/(4f)+h}\,dx=k\,{\sqrt {\frac {\pi }{f}}}\,\exp \left({\frac {g^{2}}{4f}}+h\right)}$

where f must be strictly positive for the integral to converge.

### Relation to standard Gaussian integral

The integral

${\displaystyle \int _{-\infty }^{\infty }ae^{-(x-b)^{2}/2c^{2}}\,dx}$

for some real constants a, b, c > 0 can be calculated by putting it into the form of a Gaussian integral. First, the constant a can simply be factored out of the integral. Next, the variable of integration is changed from x to y = x - b.

${\displaystyle a\int _{-\infty }^{\infty }e^{-y^{2}/2c^{2}}\,dy}$

and then to ${\displaystyle z=y/{\sqrt {2c^{2}}}}$

${\displaystyle a{\sqrt {2c^{2}}}\int _{-\infty }^{\infty }e^{-z^{2}}\,dz}$

Then, using the Gaussian integral identity

${\displaystyle \int _{-\infty }^{\infty }e^{-z^{2}}\,dz={\sqrt {\pi }}}$

we have

${\displaystyle \int _{-\infty }^{\infty }ae^{-(x-b)^{2}/2c^{2}}\,dx=a{\sqrt {2\pi c^{2}}}}$

## Two-dimensional Gaussian function

Gaussian curve with a two-dimensional domain

In two dimensions, the power to which e is raised in the Gaussian function is any negative-definite quadratic form. Consequently, the level sets of the Gaussian will always be ellipses.

A particular example of a two-dimensional Gaussian function is

${\displaystyle f(x,y)=A\exp \left(-\left({\frac {(x-x_{o})^{2}}{2\sigma _{X}^{2}}}+{\frac {(y-y_{o})^{2}}{2\sigma _{Y}^{2}}}\right)\right).}$

Here the coefficient A is the amplitude, xo,yo is the center and σx, σy are the x and y spreads of the blob. The figure on the right was created using A = 1, xo = 0, yo = 0, σx = σy = 1.

The volume under the Gaussian function is given by

${\displaystyle V=\int _{-\infty }^{\infty }\int _{-\infty }^{\infty }f(x,y)\,dx\,dy=2\pi A\sigma _{X}\sigma _{Y}.}$

In general, a two-dimensional elliptical Gaussian function is expressed as

${\displaystyle f(x,y)=A\exp \left(-\left(a(x-x_{o})^{2}+2b(x-x_{o})(y-y_{o})+c(y-y_{o})^{2}\right)\right)}$

where the matrix

${\displaystyle \left[{\begin{matrix}a&b\\b&c\end{matrix}}\right]}$

Using this formulation, the figure on the right can be created using A = 1, (xo, yo) = (0, 0), a = c = 1/2, b = 0.

### Meaning of parameters for the general equation

For the general form of the equation the coefficient A is the height of the peak and (xoyo) is the center of the blob.

If we set

{\displaystyle {\begin{aligned}a&={\frac {\cos ^{2}\theta }{2\sigma _{X}^{2}}}+{\frac {\sin ^{2}\theta }{2\sigma _{Y}^{2}}}\\[4pt]b&=-{\frac {\sin 2\theta }{4\sigma _{X}^{2}}}+{\frac {\sin 2\theta }{4\sigma _{Y}^{2}}}\\[4pt]c&={\frac {\sin ^{2}\theta }{2\sigma _{X}^{2}}}+{\frac {\cos ^{2}\theta }{2\sigma _{Y}^{2}}}\end{aligned}}}

then we rotate the blob by a clockwise angle ${\displaystyle \theta }$ (for counterclockwise rotation invert the signs in the b coefficient). This can be seen in the following examples:

 ${\displaystyle \theta =0}$ ${\displaystyle \theta =\pi /6}$ ${\displaystyle \theta =\pi /3}$

Using the following Octave code, one can easily see the effect of changing the parameters

A = 1;
x0 = 0; y0 = 0;

sigma_X = 1;
sigma_Y = 2;

[X, Y] = meshgrid(-5:.1:5, -5:.1:5);

for theta = 0:pi/100:pi
a = cos(theta)^2/(2*sigma_X^2) + sin(theta)^2/(2*sigma_Y^2);
b = -sin(2*theta)/(4*sigma_X^2) + sin(2*theta)/(4*sigma_Y^2);
c = sin(theta)^2/(2*sigma_X^2) + cos(theta)^2/(2*sigma_Y^2);

Z = A*exp( - (a*(X-x0).^2 + 2*b*(X-x0).*(Y-y0) + c*(Y-y0).^2));

waitforbuttonpress
end


Such functions are often used in image processing and in computational models of visual system function—see the articles on scale space and affine shn.

Also see multivariate normal distribution.

### Higher-order Gaussian or super-Gaussian function

A more general formulation of a Gaussian function with a flat-top and Gaussian fall-off can be taken by raising the content of the exponent to a power, ${\displaystyle P}$:

${\displaystyle f(x)=A\exp \left(-\left({\frac {(x-x_{o})^{2}}{2\sigma _{X}^{2}}}\right)^{P}\right).}$ This function is known as a super-Gaussian function and is often used for Gaussian beam formulation.[2] In a two-dimensional formulation, a Gaussian function along ${\displaystyle x}$ and ${\displaystyle y}$ can be combined with potentially different ${\displaystyle P_{X}}$ and ${\displaystyle P_{X}}$ to form an elliptical Gaussian distribution,${\displaystyle f(x,y)=A\exp \left(-\left({\frac {(x-x_{o})^{2}}{2\sigma _{X}^{2}}}+{\frac {(y-y_{o})^{2}}{2\sigma _{Y}^{2}}}\right)^{P}\right)}$ or a rectangular Gaussian distribution, ${\displaystyle f(x,y)=A\exp \left(-\left({\frac {(x-x_{o})^{2}}{2\sigma _{X}^{2}}}\right)^{P_{X}}-\left({\frac {(y-y_{o})^{2}}{2\sigma _{Y}^{2}}}\right)^{P_{Y}}\right)}$.[3]

## Multi-dimensional Gaussian function

In an ${\displaystyle n}$-dimensional space a Gaussian function can be defined as

${\displaystyle f(x)=\exp(-x^{T}Ax)\;,}$

where ${\displaystyle x=\{x_{1},\dots ,x_{n}\}}$ is a column of ${\displaystyle n}$ coordinates, ${\displaystyle A}$ is a positive-definite ${\displaystyle n\times n}$ matrix, and ${\displaystyle {}^{T}}$ denotes matrix transposition.

The integral of this Gaussian function over the whole ${\displaystyle n}$-dimensional space is given as

${\displaystyle \int _{\mathbb {R} ^{n}}\exp(-x^{T}Ax)\,dx={\sqrt {\frac {\pi ^{n}}{\det A}}}\;.}$

It can be easily calculated by diagonalizing the matrix ${\displaystyle A}$ and changing the integration variables to the eigenvectors of ${\displaystyle A}$.

More generally a shifted Gaussian function is defined as

${\displaystyle f(x)=\exp(-x^{T}Ax+s^{T}x)\;,}$

where ${\displaystyle s=\{s_{1},\dots ,s_{n}\}}$ is the shift vector and the matrix ${\displaystyle A}$ can be assumed to be symmetric, ${\displaystyle A^{T}=A}$, and positive-definite. The following integrals with this function can be calculated with the same technique,

{\displaystyle {\begin{aligned}&\int _{\mathbb {R} ^{n}}e^{-x^{T}Ax+v^{T}x}\,dx={\sqrt {\frac {\pi ^{n}}{\det {A}}}}\exp \left({\frac {1}{4}}v^{T}A^{-1}v\right)\equiv {\mathcal {M}}\;.\\[6pt]&\int _{\mathbb {R} ^{n}}e^{-x^{T}Ax+v^{T}x}\left(a^{T}x\right)\,dx=(a^{T}u)\cdot {\mathcal {M}}\;,{\text{ where }}u={\frac {1}{2}}A^{-1}v\;.\\[6pt]&\int _{\mathbb {R} ^{n}}e^{-x^{T}Ax+v^{T}x}(x^{T}Dx)\,dx=\left(u^{T}Du+{\frac {1}{2}}\operatorname {tr} (DA^{-1})\right)\cdot {\mathcal {M}}\;.\\[6pt]&\int _{\mathbb {R} ^{n}}e^{-x^{T}A'x+s'^{T}x}\left(-{\frac {\partial }{\partial x}}\Lambda {\frac {\partial }{\partial x}}\right)e^{-x^{T}Ax+s^{T}x}\,dx\\[6pt]={}&\left(2\operatorname {tr} (A'\Lambda AB^{-1})+4u^{T}A'\Lambda Au-2u^{T}(A'\Lambda s+A\Lambda s')+s'^{T}\Lambda s\right)\cdot {\mathcal {M}}\;,\\[6pt]&{\text{where }}u={\frac {1}{2}}B^{-1}v,v=s+s',B=A+A'\;.\end{aligned}}}

## Gaussian profile estimation

A number of fields such as stellar photometry, Gaussian beam characterization, and emission/absorption line spectroscopy work with sampled Gaussian functions and need to accurately estimate the height, position, and width parameters of the function. These are ${\displaystyle a}$, ${\displaystyle b}$, and ${\displaystyle c}$ for a 1D Gaussian function, ${\displaystyle A}$, ${\displaystyle (x_{0},y_{0})}$, and ${\displaystyle (\sigma _{X},\sigma _{Y})}$ for a 2D Gaussian function. The most common method for estimating the profile parameters is to take the logarithm of the data and fit a parabola to the resulting data set.[4] While this provides a simple least squares fitting procedure, the resulting algorithm is biased by excessively weighting small data values, and this can produce large errors in the profile estimate. One can partially compensate for this through weighted least squares estimation, in which the small data values are given small weights, but this too can be biased by allowing the tail of the Gaussian to dominate the fit. In order to remove the bias, one can instead use an iterative procedure in which the weights are updated at each iteration (see Iteratively reweighted least squares).[4]

Once one has an algorithm for estimating the Gaussian function parameters, it is also important to know how accurate those estimates are. While an estimation algorithm can provide numerical estimates for the variance of each parameter (i.e. the variance of the estimated height, position, and width of the function), one can use Cramér–Rao bound theory to obtain an analytical expression for the lower bound on the parameter variances, given some assumptions about the data.[5][6]

1. The noise in the measured profile is either i.i.d. Gaussian, or the noise is Poisson-distributed.
2. The spacing between each sampling (i.e. the distance between pixels measuring the data) is uniform.
3. The peak is "well-sampled", so that less than 10% of the area or volume under the peak (area if a 1D Gaussian, volume if a 2D Gaussian) lies outside the measurement region.
4. The width of the peak is much larger than the distance between sample locations (i.e. the detector pixels must be at least 5 times smaller than the Gaussian FWHM).

When these assumptions are satisfied, the following covariance matrix K applies for the 1D profile parameters ${\displaystyle a}$, ${\displaystyle b}$, and ${\displaystyle c}$ under i.i.d. Gaussian noise and under Poisson noise:[5]

${\displaystyle \mathbf {K} _{\text{Gauss}}={\frac {\sigma ^{2}}{{\sqrt {\pi }}\delta _{X}Q^{2}}}{\begin{pmatrix}{\frac {3}{2c}}&0&{\frac {-1}{a}}\\0&{\frac {2c}{a^{2}}}&0\\{\frac {-1}{a}}&0&{\frac {2c}{a^{2}}}\end{pmatrix}}\ ,\qquad \mathbf {K} _{\text{Poiss}}={\frac {1}{\sqrt {2\pi }}}{\begin{pmatrix}{\frac {3a}{2c}}&0&-{\frac {1}{2}}\\0&{\frac {c}{a}}&0\\-{\frac {1}{2}}&0&{\frac {c}{2a}}\end{pmatrix}}\ ,}$

where ${\displaystyle \delta _{X}}$ is the width of the pixels used to sample the function, ${\displaystyle Q}$ is the quantum efficiency of the detector, and ${\displaystyle \sigma }$ indicates the standard deviation of the measurement noise. Thus, the individual variances for the parameters are, in the Gaussian noise case,

{\displaystyle {\begin{aligned}\operatorname {var} (a)&={\frac {3\sigma ^{2}}{2{\sqrt {\pi }}\,\delta _{X}Q^{2}c}}\\\operatorname {var} (b)&={\frac {2\sigma ^{2}c}{\delta _{X}{\sqrt {\pi }}\,Q^{2}a^{2}}}\\\operatorname {var} (c)&={\frac {2\sigma ^{2}c}{\delta _{X}{\sqrt {\pi }}\,Q^{2}a^{2}}}\end{aligned}}}

and in the Poisson noise case,

{\displaystyle {\begin{aligned}\operatorname {var} (a)&={\frac {3a}{2{\sqrt {2\pi }}\,c}}\\\operatorname {var} (b)&={\frac {c}{{\sqrt {2\pi }}\,a}}\\\operatorname {var} (c)&={\frac {c}{2{\sqrt {2\pi }}\,a}}.\end{aligned}}}

For the 2D profile parameters giving the amplitude ${\displaystyle A}$, position ${\displaystyle (x_{0},y_{0})}$, and width ${\displaystyle (\sigma _{X},\sigma _{Y})}$ of the profile, the following covariance matrices apply:[6]

{\displaystyle {\begin{aligned}\mathbf {K} _{\text{Gauss}}={\frac {\sigma ^{2}}{\pi \delta _{X}\delta _{Y}Q^{2}}}&{\begin{pmatrix}{\frac {2}{\sigma _{X}\sigma _{Y}}}&0&0&{\frac {-1}{A\sigma _{Y}}}&{\frac {-1}{A\sigma _{X}}}\\0&{\frac {2\sigma _{X}}{A^{2}\sigma _{Y}}}&0&0&0\\0&0&{\frac {2\sigma _{Y}}{A^{2}\sigma _{X}}}&0&0\\{\frac {-1}{A\sigma _{y}}}&0&0&{\frac {2\sigma _{X}}{A^{2}\sigma _{y}}}&0\\{\frac {-1}{A\sigma _{X}}}&0&0&0&{\frac {2\sigma _{Y}}{A^{2}\sigma _{X}}}\end{pmatrix}}\\[6pt]\mathbf {K} _{\operatorname {Poisson} }={\frac {1}{2\pi }}&{\begin{pmatrix}{\frac {3A}{\sigma _{X}\sigma _{Y}}}&0&0&{\frac {-1}{\sigma _{Y}}}&{\frac {-1}{\sigma _{X}}}\\0&{\frac {\sigma _{X}}{A\sigma _{Y}}}&0&0&0\\0&0&{\frac {\sigma _{Y}}{A\sigma _{X}}}&0&0\\{\frac {-1}{\sigma _{Y}}}&0&0&{\frac {2\sigma _{X}}{3A\sigma _{Y}}}&{\frac {1}{3A}}\\{\frac {-1}{\sigma _{X}}}&0&0&{\frac {1}{3A}}&{\frac {2\sigma _{Y}}{3A\sigma _{X}}}\end{pmatrix}}.\end{aligned}}}

where the individual parameter variances are given by the diagonal elements of the covariance matrix.

## Discrete Gaussian

The discrete Gaussian kernel (solid), compared with the sampled Gaussian kernel (dashed) for scales ${\displaystyle t=0.5,1,2,4.}$

One may ask for a discrete analog to the Gaussian; this is necessary in discrete applications, particularly digital signal processing. A simple answer is to sample the continuous Gaussian, yielding the sampled Gaussian kernel. However, this discrete function does not have the discrete analogs of the properties of the continuous function, and can lead to undesired effects, as described in the article scale space implementation.

An alternative approach is to use discrete Gaussian kernel:[7]

${\displaystyle T(n,t)=e^{-t}I_{n}(t)}$

where ${\displaystyle I_{n}(t)}$ denotes the modified Bessel functions of integer order.

This is the discrete analog of the continuous Gaussian in that it is the solution to the discrete diffusion equation (discrete space, continuous time), just as the continuous Gaussian is the solution to the continuous diffusion equation.[8]

## Applications

Gaussian functions appear in many contexts in the natural sciences, the social sciences, mathematics, and engineering. Some examples include:

## Notes

1. ^ Using the logarithmic identity ${\displaystyle \log x=-\log \left({\frac {1}{x}}\right)}$, this expression can be transformed to ${\displaystyle \mathrm {FWHM} =2{\sqrt {-2\ln 0.5}}\ c}$.

## References

1. ^ Weisstein, Eric W. "Fourier Transform – Gaussian". MathWorld. Retrieved 19 December 2013.
2. ^ Parent, A., M. Morin, and P. Lavigne. "Propagation of super-Gaussian field distributions." Optical and quantum electronics 24.9 (1992): S1071-S1079.
3. ^ "GLAD optical software commands manual, Entry on GAUSSIAN command" (PDF). Applied Optics Research. 2016-12-15.
4. ^ a b Hongwei Guo, "A simple algorithm for fitting a Gaussian function," IEEE Sign. Proc. Mag. 28(9): 134-137 (2011).
5. ^ a b N. Hagen, M. Kupinski, and E. L. Dereniak, "Gaussian profile estimation in one dimension," Appl. Opt. 46:5374–5383 (2007)
6. ^ a b N. Hagen and E. L. Dereniak, "Gaussian profile estimation in two dimensions," Appl. Opt. 47:6842–6851 (2008)
7. ^ Lindeberg, T., "Scale-space for discrete signals," PAMI(12), No. 3, March 1990, pp. 234–254.
8. ^ Campbell, J, 2007, The SMM model as a boundary value problem using the discrete diffusion equation, Theor Popul Biol. 2007 Dec;72(4):539–46.
9. ^ Honarkhah, M and Caers, J, 2010, Stochastic Simulation of Patterns Using Distance-Based Pattern Modeling, Mathematical Geosciences, 42: 487–517