private void changeValueRandomly(Random r,int numOfValues,int indexOfAtt,Instance instance,boolean useMissing){
  int currValue;
  if (instance.isMissing(indexOfAtt)) {
    currValue=numOfValues;
  }
 else {
    currValue=(int)instance.value(indexOfAtt);
  }
  if ((numOfValues == 2) && (!instance.isMissing(indexOfAtt))) {
    instance.setValue(indexOfAtt,(currValue + 1) % 2);
  }
 else {
    while (true) {
      int newValue;
      if (useMissing) {
        newValue=(int)(r.nextDouble() * (numOfValues + 1));
      }
 else {
        newValue=(int)(r.nextDouble() * numOfValues);
      }
      if (newValue != currValue) {
        if (newValue == numOfValues) {
          instance.setMissing(indexOfAtt);
        }
 else {
          instance.setValue(indexOfAtt,newValue);
        }
        break;
      }
    }
  }
}

private void changeValueRandomly ( Random r , int numOfValues , int indexOfAtt , Instance instance , boolean useMissing ) { int currValue ; if ( instance . isMissing ( indexOfAtt ) ) { currValue = numOfValues ; } else { currValue = ( int ) instance . value ( indexOfAtt ) ; } if ( ( numOfValues == 2 ) && ( ! instance . isMissing ( indexOfAtt ) ) ) { instance . setValue ( indexOfAtt , ( currValue + 1 ) % 2 ) ; } else { while ( true ) { int newValue ; if ( useMissing ) { newValue = ( int ) ( r . nextDouble ( ) * ( numOfValues + 1 ) ) ; } else { newValue = ( int ) ( r . nextDouble ( ) * numOfValues ) ; } if ( newValue != currValue ) { if ( newValue == numOfValues ) { instance . setMissing ( indexOfAtt ) ; } else { instance . setValue ( indexOfAtt , newValue ) ; } break ; } } } }
method to set a new value
