code: public Double earlyAbandonedDistance(double[] series1, double[] series2, double cutoff)
        throws Exception {
      if (series1.length == series2.length) {
        double cutOff2 = cutoff;
        if (Double.MAX_VALUE != cutoff) {
          cutOff2 = cutoff * cutoff;
        }
        Double res = 0D;
        for (int i = 0; i < series1.length; i++) {
          res = res + distance2(series1[i], series2[i]);
          if (res > cutOff2) {
            return Double.NaN;
          }
        }
        return Math.sqrt(res);
      }
      else {
        throw new Exception("Exception in Euclidean distance: array lengths are not equal");
      }
    }
docs: Implements Euclidean distance with early abandoning.
  
  @param series1 the first series.
  @param series2 the second series.
  @param cutoff the cut-off threshold
  @return the distance if it is less than cutoff or Double.NAN if it is above.
  
  @throws Exception if error occurs.