;----------------------------------------------------------------- ; gauss.pro ; ; written by Andreas Reigber ;------------------------------------------------------------------ ; Calculates a 1D Gauss distribution ; ; Usage: ; res = gauss(len,sigma,mu) ; ; len = length of the resulting array ; sigma = standard deviation ; mu = position of maximum (optional, default=0) ; ;------------------------------------------------------------------ ; This software has been released under the terms of the GNU Public ; license. See http://www.gnu.org/copyleft/gpl.html for details. ;------------------------------------------------------------------ function gauss,len,sigma,mu if n_params() lt 2 then begin print,'Usage: res = gauss(length,sigma,mu)' print,'' print,'ERROR: Must specify at least array length and sigma' return, -1 endif sigma = float(sigma) x = shift(findgen(len)-len/2,len/2) gauss = 1/(sqrt(2*!pi)*sigma)*exp(-(x^2)/(2*sigma^2)) if n_params() eq 3 then gauss = shift(gauss,mu) return,gauss end