FUNCTION FITAGAUSS,X,Y,A,SIGMAA ;+ ; NAME: ; FITAGAUSS ; PURPOSE: ; A version of CURVEFIT that fits a Gaussian to the data, using the ; mean absolute deviation rather than the chi^2. DESIGNED ONLY FOR ; USE BY HISTOGAUSS AND HALFAGAUSS. EMPLOY ELSEWHERE AT USER'S RISK. ; CALLING SEQUNENCE: ; value = FITAGAUSS( X, Y, A, SIGMAA ) ; INPUT: ; X, Y = the points to fit ; A = the vector of parameters: [height,center,width,Y offset]. The ; offset is optional. If the A input has 3 element, no offset is returned. ; If A has four elements, the last parameter is a constant offset: ; y = G(x) + A(3) ; OUTPUT: ; Value - The value of the Gaussian fit at the input points. ; SIGMAA = uncertainties of parameters ; REVISION HISTORY: ; Written, ; H.T. Freudenreich, ?/? ;- ON_ERROR,2 ;RETURN TO CALLER IF ERROR W=Y W(*)=1. EPS=1.0E-8 A = 1.*A ;MAKE PARAMS FLOATING NTERMS = N_ELEMENTS(A) ;# OF PARAMS. NPTS = N_ELEMENTS(Y) M0 = (NPTS-1)/2 NFREE = (N_ELEMENTS(Y)