public static DoubleVector dchisqLog(double x,DoubleVector ncp){
  DoubleVector dLog=new DoubleVector(ncp.size());
  double xh=Math.sqrt(x);
  double mean;
  for (int i=0; i < ncp.size(); i++) {
    mean=Math.sqrt(ncp.get(i));
    if (ncp.get(i) == 0.0)     dLog.set(i,dchisqLog(x));
 else     dLog.set(i,Math.log(dnorm(xh - mean) + dnorm(-xh - mean)) - Math.log(2 * xh));
  }
  return dLog;
}

public static DoubleVector dchisqLog ( double x , DoubleVector ncp ) { DoubleVector dLog = new DoubleVector ( ncp . size ( ) ) ; double xh = Math . sqrt ( x ) ; double mean ; for ( int i = 0 ; i < ncp . size ( ) ; i ++ ) { mean = Math . sqrt ( ncp . get ( i ) ) ; if ( ncp . get ( i ) == 0.0 ) dLog . set ( i , dchisqLog ( x ) ) ; else dLog . set ( i , Math . log ( dnorm ( xh - mean ) + dnorm ( - xh - mean ) ) - Math . log ( 2 * xh ) ) ; } return dLog ; }
returns the log - density of a set of noncentral chi - squared distributions .
