private Double[][] randomCentroids( int numCentroids ) {
		int features = getTrainSet().getAttributes().size();

		double[][] maxmin = new double[features][2];
		for( int a = 0; a < features; a++ ) {
			maxmin[a][0] = +Double.MAX_VALUE;
			maxmin[a][1] = -Double.MAX_VALUE;
		}

		// find min and max for each attribute
		for( Pattern instance : getTrainSet() ) {
			Double[] vector = instance.toDoubleVector();
			for( int i = 0; i < vector.length; i++ ) {
				double feature = vector[i];
				if( feature < maxmin[i][0] )
					maxmin[i][0] = feature;
				if( feature > maxmin[i][1] )
					maxmin[i][1] = feature;

			}
		}

		Random random = new Random();

		Double[][] centroids = new Double[numCentroids][];
		for( int centroid = 0; centroid < numCentroids; centroid++ ) {
			centroids[centroid] = new Double[features];
			for( int a = 0; a < features; a++ ) {
				centroids[centroid][a] = maxmin[a][0] + ( maxmin[a][1] - maxmin[a][0] ) * random.nextDouble();
			}
		}

		return centroids;
	}