* Last processed by NICE on 12-Jun-2000 15:53:00
* Customized for :  IEEE, LINUX, UNIX, MOTIF, F77
      FUNCTION FCHISQ(X,N,NFREE,XFIT,GOOD)
C----------------------------------------------------------------------
C	calcul de la dispersion quadratique moyenne
C----------------------------------------------------------------------
      INTEGER N,NFREE
      REAL*8 FCHISQ
      REAL*8 X(1),XFIT(1)
      LOGICAL GOOD(1)
*
      REAL*8 RES
      INTEGER J,KP
*
      FCHISQ=0.
      KP = 0
      DO J=1,N
         IF (GOOD(J)) THEN
            RES = X(J)-XFIT(J)
            FCHISQ=FCHISQ+RES**2
            KP = KP+1
         ENDIF
      ENDDO
      FCHISQ = FCHISQ/(KP-NFREE)
      END
