public static double findMinDistance(Instances inst, int attrIndex) {
    double min = Double.MAX_VALUE;
    int numInst = inst.numInstances();
    double diff;
    if (numInst < 2) return min;
    int begin = -1;
    Instance instance = null;
    do { 
      begin++;
      if (begin < numInst) 
	{ instance = inst.instance(begin); }
    } while (begin < numInst && instance.isMissing(attrIndex)); 

    double secondValue = inst.instance(begin).value(attrIndex);
    for (int i = begin; i < numInst && !inst.instance(i).isMissing(attrIndex);  i++) {
      double firstValue = secondValue; 
      secondValue = inst.instance(i).value(attrIndex);
      if (secondValue != firstValue) {
	diff = secondValue - firstValue;
	if (diff < min && diff > 0.0) {
	  min = diff;
	}
      }
    }
    return min;
  }