public static DoubleVector rchisq(int n,double ncp,Random random){
  DoubleVector v=new DoubleVector(n);
  double mean=Math.sqrt(ncp);
  double x;
  for (int i=0; i < n; i++) {
    x=random.nextGaussian() + mean;
    v.set(i,x * x);
  }
  return v;
}

public static DoubleVector rchisq ( int n , double ncp , Random random ) { DoubleVector v = new DoubleVector ( n ) ; double mean = Math . sqrt ( ncp ) ; double x ; for ( int i = 0 ; i < n ; i ++ ) { x = random . nextGaussian ( ) + mean ; v . set ( i , x * x ) ; } return v ; }
generates a sample of a chi - square distribution .
