private void changeValueRandomly(Random r, int numOfValues,
                                   int indexOfAtt, 
                                   Instance instance, 
                                   boolean useMissing) {
    int currValue;

    // get current value 
    // if value is missing set current value to number of values
    // whiche is the highest possible value plus one 
    if (instance.isMissing(indexOfAtt)) {
      currValue = numOfValues;
    } else {
      currValue = (int) instance.value(indexOfAtt);
    }

    // with only two possible values it is easier
    if ((numOfValues == 2) && (!instance.isMissing(indexOfAtt))) {
	instance.setValue(indexOfAtt, (double) ((currValue+1)% 2));
    } else {
      // get randomly a new value not equal to the current value
      // if missing values are used as values they must be treated
      // in a special way
      while (true) {
	  int newValue;
        if (useMissing) {
          newValue = (int) (r.nextDouble() * (double) (numOfValues + 1));
        } else {
          newValue = (int) (r.nextDouble() * (double) numOfValues);
        }
        // have we found a new value?
        if (newValue != currValue) { 
          // the value 1 above the highest possible value (=numOfValues)
          // is used as missing value
          if (newValue == numOfValues) { instance.setMissing(indexOfAtt); }
          else { instance.setValue(indexOfAtt, (double) newValue); }
          break;
        }
      }
    }
  }