code: public static int probRound(double value, Random rand) {
  
      if (value >= 0) {
        double lower = Math.floor(value);
        double prob = value - lower;
        if (rand.nextDouble() < prob) {
  	return (int)lower + 1;
        } else {
  	return (int)lower;
        }
      } else {
        double lower = Math.floor(Math.abs(value));
        double prob = Math.abs(value) - lower;
        if (rand.nextDouble() < prob) {
  	return -((int)lower + 1);
        } else {
  	return -(int)lower;
        }
      }
    }
docs: Rounds a double to the next nearest integer value in a probabilistic
  fashion (e.g. 0.8 has a 20% chance of being rounded down to 0 and a
  80% chance of being rounded up to 1). In the limit, the average of
  the rounded numbers generated by this procedure should converge to
  the original double.
  
  @param value the double value
  @param rand the random number generator
  @return the resulting integer value