      function chi2pdf_pd(chi2) ! bernd berg jul 5 1999.
c chi2 per degree of freedom probability density.
      include '../../libs/fortran/implicit.sta'
      include '../../libs/fortran/constants.par'
      common /chi2par/ nf
      a=half*nf
      aln=log(a)
      cln=log(chi2)
      yln=aln-a*chi2+(a-one)*(aln+cln)-gamma_ln(a)
      chi2pdf_pd=exp(yln)
      return
      end
