public static double dchisq(double x,double ncp){
  if (ncp == 0.0)   return dchisq(x);
  double xh=Math.sqrt(x);
  double mean=Math.sqrt(ncp);
  return (dnorm(xh - mean) + dnorm(-xh - mean)) / (2 * xh);
}

public static double dchisq ( double x , double ncp ) { if ( ncp == 0.0 ) return dchisq ( x ) ; double xh = Math . sqrt ( x ) ; double mean = Math . sqrt ( ncp ) ; return ( dnorm ( xh - mean ) + dnorm ( - xh - mean ) ) / ( 2 * xh ) ; }
returns the density of the noncentral chi - squared distribution .
