      function chi2pdf_qdf(chi2) ! bernd berg, july 5 1999.
c chi2 per degree of freedom: peaked cumulative distribution function.
      include '../../libs/fortran/implicit.sta'
      include '../../libs/fortran/constants.par'
      common /chi2par/ nf
      a=half*nf
      x=half*nf*chi2
      chi2pdf_qdf=gamma_p(a,x)
      if(chi2pdf_qdf.gt.half) chi2pdf_qdf=one-chi2pdf_qdf
      return
      end
