private Point[] chooseRandomCentres(int k, int n, int d, Point points[]) {

        //array to store the choosen centres
        Point[] centres = new Point[k];

        //choose the first centre (each point has the same probability of being choosen)
        int i = 0;

        int next = 0;
        int j = 0;
        do { //only choose from the n-i points not already choosen
            next = this.clustererRandom.nextInt(n - 1);

            //check if the choosen point is not a dummy
        } while (points[next].weight < 1);

        //set j to next unchoosen point
        j = next;
        //copy the choosen point to the array
        centres[i] = points[j].clone();

        //set the current centre for all points to the choosen centre
        for (i = 0; i < n; i++) {
            points[i].centreIndex = 0;
            points[i].curCost = points[i].costOfPointToCenter(centres[0]);

        }
        //choose centre 1 to k-1 with the kMeans++ distribution
        for (i = 1; i < k; i++) {

            double cost = 0.0;
            for (j = 0; j < n; j++) {
                cost += points[j].curCost;
            }

            double random = 0;
            double sum = 0.0;
            int pos = -1;

            do {
                random = this.clustererRandom.nextDouble();//genrand_real3();
                sum = 0.0;
                pos = -1;

                for (j = 0; j < n; j++) {
                    sum = sum + points[j].curCost;
                    if (random <= sum / cost) {
                        pos = j;
                        break;
                    }
                }
            } while (points[pos].weight < 1);

            //copy the choosen centre
            centres[i] = points[pos].clone();
            //check which points are closest to the new centre
            for (j = 0; j < n; j++) {
                double newCost = points[j].costOfPointToCenter(centres[i]);
                if (points[j].curCost > newCost) {
                    points[j].curCost = newCost;
                    points[j].centreIndex = i;
                }
            }

        }

        /*printf("random centres: \n");
          for(i = 0; i < k; i++){
              //printf("%d: (",i);
              int l = 0;
              for(l = 0; l < centres[i].dimension; l++){
                  printf("%f,",centres[i].coordinates[l] / centres[i].weight);
              }
              printf(")\n");
          }*/

        return centres;
    }