docs: public static double cleanProbability(double prob, double epsilon, boolean allowOne) {
      if (prob < -epsilon || prob > (1.0 + epsilon)) {
        throw new InvalidProbabilityException(prob);
      }
  
      if (prob < epsilon) {
        prob = epsilon;
      } else {
        final double limit = allowOne ? 1.0 : (1.0 - epsilon);
        if (prob > limit) {
          prob = limit;
        }
      }
  
      return prob;
    }