PRO eval_chi_sqrd_nu, npts, npar, values, varis, predicts, $ chi_sqrd_nu, q ; Computes the reduced chi square and the probability that ; it exceeds chance agreement. ; ; Author: Robert Kessel ; Electro-Optics Technology Section ; Code 8123 ; Naval Research Laboratory ; Washington, D.C. 20375-5354 ; email: kessel@ncst.nrl.navy.mil ; ; This code was written for Bill Palya's and Don Walter's ; use at JSU. However, anyone else who finds it useful ; should feel free to use it, rewrite it, or whatever else, ; save charging any money, goods or services from any other ; person for the code or use thereof. ; 8/8/00 nu = npts - npar ; compute reduced chi square with trap on zero variance chi_sqrd_nu = 0. FOR i=0,npts-1 DO BEGIN IF (varis[i] GT 0.) THEN BEGIN resid_sqrd = (values[i] - predicts[i])^2 chi_sqrd_nu = chi_sqrd_nu + resid_sqrd/varis[i] ENDIF ELSE BEGIN PRINT, 'At data point ', i PRINT, ' ' STOP, 'Failed greater than zero variance in eval_chi_sqrd_nu' ENDELSE ENDFOR chi_sqrd_nu = chi_sqrd_nu/nu q = q_chi_sqrd_nu(nu, chi_sqrd_nu) END