int instIndex = Math.abs(RandomO.nextInt()) % m_instances.numInstances();
do { instIndex = Math.abs(RandomO.nextInt()) % m_instances.numInstances(); } while (selected[instIndex]);
  public void buildClusterer(Instances data) throws Exception {        if (data.checkForStringAttributes()) {      throw  new Exception("Can't handle string attributes!");    }    m_ReplaceMissingFilter = new ReplaceMissingValuesFilter();    m_ReplaceMissingFilter.setInputFormat(data);    m_instances = Filter.useFilter(data, m_ReplaceMissingFilter);    m_Min = new double [m_instances.numAttributes()];    m_Max = new double [m_instances.numAttributes()];    for (int i = 0; i < m_instances.numAttributes(); i++) {      m_Min[i] = m_Max[i] = Double.NaN;    }    for (int i = 0; i < m_instances.numInstances(); i++) {      updateMinMax(m_instances.instance(i));    }        m_ClusterCentroids = new Instances(m_instances, m_NumClusters);    m_ClusterAssignments = new int [m_instances.numInstances()];    Random RandomO = new Random(m_Seed);    for (int i = 0; i < m_NumClusters; i++) {      int instIndex = Math.abs(RandomO.nextInt()) % m_instances.numInstances();      m_ClusterCentroids.add(m_instances.instance(instIndex));    }    boolean converged = false;    while (!converged) {      converged = true;      for (int i = 0; i < m_instances.numInstances(); i++) {	Instance toCluster = m_instances.instance(i);	int newC = clusterProcessedInstance(toCluster);	if (newC != m_ClusterAssignments[i]) {	  converged = false;	}	m_ClusterAssignments[i] = newC;      }            Instances [] tempI = new Instances[m_NumClusters];      // update centroids      m_ClusterCentroids = new Instances(m_instances, m_NumClusters);      for (int i = 0; i < m_NumClusters; i++) {	tempI[i] = new Instances(m_instances, 0);      }      for (int i = 0; i < m_instances.numInstances(); i++) {	tempI[m_ClusterAssignments[i]].add(m_instances.instance(i));      }      for (int i = 0; i < m_NumClusters; i++) {	double [] vals = new double[m_instances.numAttributes()];	for (int j = 0; j < m_instances.numAttributes(); j++) {	  vals[j] = tempI[i].meanOrMode(j);	}	m_ClusterCentroids.add(new Instance(1.0, vals));      }    }  }