public int[] sampling(int k) throws OutOfRangeSampleSize{
		int centroidIndexes[]=new int[k];
		//choose k random different centroids in data.

		Random rand=new Random();
		rand.setSeed(System.currentTimeMillis());

		if(k <= 0 || k > this.distinctTuples)	
			throw new OutOfRangeSampleSize("Errore! - Numero di iterate inserito non valido!\nIntervallo valori accettati per k: 1 - " + this.distinctTuples);
		{
			for (int i=0; i<k; i++){
				boolean found=false;
				int c;
				do
				{
					found=false;
					c=rand.nextInt(getNumberOfExamples());
					// verify that centroid[c] is not equal to a centroide already stored in CentroidIndexes
					for(int j=0;j<i;j++)
						if(compare(centroidIndexes[j],c)){
							found=true;
							break;
						}
				}
				while(found);
				centroidIndexes[i]=c;
			}
		}

		return centroidIndexes;
	}