public Instances generateExamples() throws Exception {
    Instances format = getDatasetFormat();
    Instance example = null;

    if (format == null) 
      throw new Exception("Dataset format not defined.");

    // generate examples for one cluster after another
    for (int cNum = 0; cNum < getClusters().length; cNum++) {
      SubspaceClusterDefinition cl  = (SubspaceClusterDefinition) getClusters()[cNum];

      //get the number of instances to create
      int instNum = cl.getNumInstances();

      //class value is c + cluster number
      String cName = "c" + cNum;

      switch (cl.getClusterType().getSelectedTag().getID()) {
        case (UNIFORM_RANDOM):
          for (int i = 0; i < instNum; i++) {
            // generate example
            example = generateExample(format, getRandom(), cl, cName);
            if (example != null)
              format.add(example);
          }
          break;
        case (TOTAL_UNIFORM):
          // generate examples
          if (!cl.isInteger())
            generateUniformExamples(format, instNum, cl, cName);
          else
            generateUniformIntegerExamples(format, instNum, cl, cName);
          break;
        case (GAUSSIAN):
          // generate examples
          generateGaussianExamples(format, instNum, getRandom(), cl, cName);
          break;
      }
    }

    return format;
  }