public static void meanVector(Vec mean,DataSet dataSet){
  if (dataSet.getSampleSize() == 0)   throw new ArithmeticException("Can not compute the mean of zero data points");
  double sumOfWeights=0;
  for (int i=0; i < dataSet.getSampleSize(); i++) {
    DataPoint dp=dataSet.getDataPoint(i);
    double w=dp.getWeight();
    sumOfWeights+=w;
    mean.mutableAdd(w,dp.getNumericalValues());
  }
  mean.mutableDivide(sumOfWeights);
}

public static void meanVector ( Vec mean , DataSet dataSet ) { if ( dataSet . getSampleSize ( ) == 0 ) throw new ArithmeticException ( "Can not compute the mean of zero data points" ) ; double sumOfWeights = 0 ; for ( int i = 0 ; i < dataSet . getSampleSize ( ) ; i ++ ) { DataPoint dp = dataSet . getDataPoint ( i ) ; double w = dp . getWeight ( ) ; sumOfWeights += w ; mean . mutableAdd ( w , dp . getNumericalValues ( ) ) ; } mean . mutableDivide ( sumOfWeights ) ; }
computes the weighted mean of the data set
