nextBoolBiased method

bool nextBoolBiased(
  1. double input,
  2. double target
)

Implementation

bool nextBoolBiased(double input, double target) {
  if (input >= target) {
    return true;
  } else {
    final difference = (input - target).abs();
    final probability = 1 - (difference / target);
    return nextDouble() <= probability;
  }
}