Getting Started | Documentation | Glish | Learn More | Programming | Contact Us |
Version 1.9 Build 1556 |
|
Package | utility | |
Module | mathematics |
include "gaussian.g"
The gaussian1d function evaluates one-dimensional Gaussians. You can specify the peak height of the Gaussian, the center of the Gaussian and the width of the Gaussian.
The width of the Gaussian is defined to be the full width at half-maximum (FWHM). If you prefer to use ``natural'' widths, a constant fwhm_to_natural is provided1.3. To get a natural width, multiply the FWHM by this constant 1.4. Similarly the FWHM is derived by dividing the natural width by this constant.
You can evaluate the Gaussian at a number of positions by passing the function a vector for ``x'' instead of a scalar.
x | in | values at which to evaluate the Gaussian | |
Allowed: | double | ||
Default: | no default | ||
height | in | maximum value of the Gaussian | |
Allowed: | double | ||
Default: | 1.0 | ||
center | in | location of the maximum value of the Gaussian | |
Allowed: | double | ||
Default: | 0.0 | ||
fwhm | in | width of the gaussian | |
Allowed: | double | ||
Default: | 1/fwhm_to_natural |
include 'gaussian.g'; x := 1:100; y := gaussian1d(x, height=3, center=30, fwhm=20);And then plot the example, marking the peak and FWHM of the Gaussian.
include 'pgplotter.g'; pg := pgplotter(); pg.env(1, 100, 0, 3, 0, 0); pg.line(x,y); # Plot the Gaussian pg.line([30,30], [0, 3]); # Show the center # Show the FWHM pg.line([30-20/2, 30-20/2, 30+20/2, 30+20/2], # x [0, 3/2, 3/2, 0]); # y