src/main/java/pt/it/av/tnav/ml/clustering/partition/Kmedoids.java
protected static <D extends Distance<D>> List<Cluster<D>> init(final List<D> dps, final int mappings[], final int k) {
    final List<Cluster<D>> clusters = new ArrayList<>(k);
    final int idxs[] = new int[dps.size()];

    for (int i = 1; i < idxs.length; i++) {
      idxs[i] = i;
    }

    ArrayUtils.shuffle(idxs);
    for (int i = 0; i < k; i++) {
      clusters.add(new Cluster<D>(dps.get(idxs[i])));
      mappings[idxs[i]] = i;
    }
    return clusters;
  }
/**
   * Create and initializes the initial centroids and clusters.
   * 
   * @param dps List of data points (Any class that implements {@link Distance})
   * @param k   number of clusters
   * @param <D>
   * @return
   */
Create and initializes the initial centroids and clusters.

@param dps List of data points (Any class that implements  Distance)
@param k   number of clusters
@param 
@return
Create and initializes the initial centroids and clusters . @param dps List of data points ( Any class that implements Distance ) @param k number of clusters @param @return
protected static <D extends Distance<D>> List<Cluster<D>> init(final List<D> dps, final int mappings[], final int k) {
    final List<Cluster<D>> clusters = new ArrayList<>(k);
    final int idxs[] = new int[dps.size()];
    for (int i = 1; i < idxs.length; i++) {
      idxs[i] = i;
    }
    ArrayUtils.shuffle(idxs);
    for (int i = 0; i < k; i++) {
      clusters.add(new Cluster<D>(dps.get(idxs[i])));
      mappings[idxs[i]] = i;
    }
    return clusters;
  }
protected static < D extends Distance < D > > List < Cluster < D > > init ( final List < D > dps , final int mappings [ ] , final int k ) { final List < Cluster < D > > clusters = new ArrayList < > ( k ) ; final int idxs [ ] = new int [ dps . size ( ) ] ; for ( int i = 1 ; i < idxs . length ; i ++ ) { idxs [ i ] = i ; } ArrayUtils . shuffle ( idxs ) ; for ( int i = 0 ; i < k ; i ++ ) { clusters . add ( new Cluster < D > ( dps . get ( idxs [ i ] ) ) ) ; mappings [ idxs [ i ] ] = i ; } return clusters ; }
Create and initializes the initial centroids and clusters.
Create and initializes the initial centroids and clusters .