src/main/java/pt/it/av/tnav/ml/clustering/cluster/ClusterUtils.java
public static <D extends Distance<D>> double avgDistortion(List<Cluster<D>> clusters) {
    double rv = 0;
    // Penalizes empty clusters and clusters with only a element
    if (clusters.isEmpty() || singleElementClusters(clusters))
      rv = Double.POSITIVE_INFINITY;
    else {
      double distortion = 0.0;
      int n = 0;
      for (Cluster<D> c : clusters)
        if(c != null) {
          distortion += c.distortion();
          n++;
        }
      rv = distortion / n;
    }
    return rv;
  }
/**
   * Returns the average distortion of cluster's list.
   * Null clusters will not be considered.
   * Empty or clusters with a single element will be penalized with infinity distortion.
   *
   * @param clusters the list of clusters.
   * @param <D> Any Class that implements {@link Distance} interface.
   * @return the average distortion of cluster's list.
   */
Returns the average distortion of cluster's list.
Null clusters will not be considered.
Empty or clusters with a single element will be penalized with infinity distortion.

@param clusters the list of clusters.
@param  Any Class that implements  Distance interface.
@return the average distortion of cluster's list.
Returns the average distortion of cluster ' s list . Null clusters will not be considered . Empty or clusters with a single element will be penalized with infinity distortion . @param clusters the list of clusters . @param Any Class that implements Distance interface . @return the average distortion of cluster ' s list .
public static <D extends Distance<D>> double avgDistortion(List<Cluster<D>> clusters) {
    double rv = 0;
    if (clusters.isEmpty() || singleElementClusters(clusters))
      rv = Double.POSITIVE_INFINITY;
    else {
      double distortion = 0.0;
      int n = 0;
      for (Cluster<D> c : clusters)
        if(c != null) {
          distortion += c.distortion();
          n++;
        }
      rv = distortion / n;
    }
    return rv;
  }
public static < D extends Distance < D > > double avgDistortion ( List < Cluster < D > > clusters ) { double rv = 0 ; if ( clusters . isEmpty ( ) || singleElementClusters ( clusters ) ) rv = Double . POSITIVE_INFINITY ; else { double distortion = 0.0 ; int n = 0 ; for ( Cluster < D > c : clusters ) if ( c != null ) { distortion += c . distortion ( ) ; n ++ ; } rv = distortion / n ; } return rv ; }
Returns the average distortion of cluster's list.
Returns the average distortion of cluster ' s list .
// Penalizes empty clusters and clusters with only a element