docs: private int doBatchKmeans () {
  
  		System.out.println("\nBegining a new iteration of K-Means...");
  
  		int numReassigned = 0;
  
  		/* Clear records for incremental k-means */
  
  		for (int i = 0; i < this.centroids.length; ++i) {
  			this.newClusters[i] = new ArrayList<Instance>();
  			this.newCentroids[i] = new HashSparseVector();
  			this.newQualities[i] = 0.0f;
  		}
  
  		for (int clusterNum = 0; clusterNum < this.centroids.length; ++clusterNum) {    // iterate over clusters
  			for (int docNum = 0; docNum < this.assignedClusters[clusterNum].size();	++docNum) {    // iterate over docs
  
  				/*
  				 *  Store the document the loops have selected in the 'doc' variable.
  				 * Store is vector in the 'docVec' variable for easy access.
  				 */
  				Instance doc = this.assignedClusters[clusterNum].get(docNum);
  				HashSparseVector docVec = (HashSparseVector) doc.getData();
  
  				int bestClusterNum = clusterNum;    // Assume we are already in the best cluster.
  				double distanceToCurrentCentroid =
  					this.centroids[clusterNum].distanceEuclidean(docVec);
  				double squareDistanceOfBestCluster = distanceToCurrentCentroid;
  
  				for (int i = 0; i < this.centroids.length; ++i) {
  
  					double distance = 0.0;
  
  					// see which centroid is closest to docVec
  					if (clusterNum == i) {    // We know the distance in its' current cluster.
  						distance = distanceToCurrentCentroid;
  					} else {
  						distance = this.centroids[i].distanceEuclidean(docVec);
  
  					}
  
  					if (distance < squareDistanceOfBestCluster) {
  						squareDistanceOfBestCluster = distance;
  						bestClusterNum = i;
  					}
  				}
  
  				if (bestClusterNum != clusterNum) {    // we moved a document!
  					++numReassigned;
  				}
  
  				this.newClusters[bestClusterNum].add(doc);
  				this.newCentroids[bestClusterNum].plus(docVec);
  			}
  		}
  
  		// Calculate the centroids of the clusters
  		for (int i = 0; i < newClusters.length; ++i) {
  			this.newCentroids[i].scaleDivide(this.newClusters[i].size());
  
  			this.newQualities[i] = this.calculateClusterQuality(this.newClusters[i],
  					this.newCentroids[i]);
  
  			System.out.println("new cluster " + i + " Viarances: " +
  					this.newQualities[i] + " Num: "+ newClusters[i].size());
  		}
  
  		return (numReassigned);
  	}