public static double logpdf(double x,double dof){
  if (x <= 0) {
    return Double.NEGATIVE_INFINITY;
  }
  if (dof <= 0) {
    return Double.NaN;
  }
  final double k=dof * .5;
  final double twox=x * 2.0;
  return twox == Double.POSITIVE_INFINITY ? Double.NEGATIVE_INFINITY : (k - 1.0) * Math.log(twox) - twox - logGamma(k) + MathUtil.LOG2;
}

public static double logpdf ( double x , double dof ) { if ( x <= 0 ) { return Double . NEGATIVE_INFINITY ; } if ( dof <= 0 ) { return Double . NaN ; } final double k = dof * .5 ; final double twox = x * 2.0 ; return twox == Double . POSITIVE_INFINITY ? Double . NEGATIVE_INFINITY : ( k - 1.0 ) * Math . log ( twox ) - twox - logGamma ( k ) + MathUtil . LOG2 ; }
chi - squared distribution pdf ( with 0 . 0 for x & lt ; 0 )
