@Override public Instance generateExample() throws Exception {
  Instance result;
  int centroid;
  double[] atts;
  double magnitude;
  double desiredMag;
  double scale;
  int i;
  double label;
  Random rand;
  result=null;
  rand=getRandom();
  if (m_DatasetFormat == null) {
    throw new Exception("Dataset format not defined.");
  }
  centroid=chooseRandomIndexBasedOnProportions(m_centroidWeights,rand);
  label=m_centroidClasses[centroid];
  atts=new double[getNumAttributes() + 1];
  for (i=0; i < getNumAttributes(); i++) {
    atts[i]=(rand.nextDouble() * 2.0) - 1.0;
  }
  atts[atts.length - 1]=label;
  magnitude=0.0;
  for (i=0; i < getNumAttributes(); i++) {
    magnitude+=atts[i] * atts[i];
  }
  magnitude=Math.sqrt(magnitude);
  desiredMag=rand.nextGaussian() * m_centroidStdDevs[centroid];
  scale=desiredMag / magnitude;
  for (i=0; i < getNumAttributes(); i++) {
    atts[i]*=scale;
    atts[i]+=m_centroids[centroid][i];
    result=new DenseInstance(1.0,atts);
  }
  result.setDataset(m_DatasetFormat);
  return result;
}

@ Override public Instance generateExample ( ) throws Exception { Instance result ; int centroid ; double [ ] atts ; double magnitude ; double desiredMag ; double scale ; int i ; double label ; Random rand ; result = null ; rand = getRandom ( ) ; if ( m_DatasetFormat == null ) { throw new Exception ( "Dataset format not defined." ) ; } centroid = chooseRandomIndexBasedOnProportions ( m_centroidWeights , rand ) ; label = m_centroidClasses [ centroid ] ; atts = new double [ getNumAttributes ( ) + 1 ] ; for ( i = 0 ; i < getNumAttributes ( ) ; i ++ ) { atts [ i ] = ( rand . nextDouble ( ) * 2.0 ) - 1.0 ; } atts [ atts . length - 1 ] = label ; magnitude = 0.0 ; for ( i = 0 ; i < getNumAttributes ( ) ; i ++ ) { magnitude += atts [ i ] * atts [ i ] ; } magnitude = Math . sqrt ( magnitude ) ; desiredMag = rand . nextGaussian ( ) * m_centroidStdDevs [ centroid ] ; scale = desiredMag / magnitude ; for ( i = 0 ; i < getNumAttributes ( ) ; i ++ ) { atts [ i ] *= scale ; atts [ i ] += m_centroids [ centroid ] [ i ] ; result = new DenseInstance ( 1.0 , atts ) ; } result . setDataset ( m_DatasetFormat ) ; return result ; }
generates one example of the dataset .
