nextInRange method

num nextInRange(
  1. num start,
  2. num end, {
  3. InverseCdf? inverseCdf,
})

Generates a random floating point value in the range from start, inclusive, to end, exclusive.

  • start: left boundary of the interval.
  • end: right boundary of the interval, start <= end.
  • inverseCdf: inverse of the cummulative probability distribution function with non-zero support over the range start...end.
  • If inverseCdf == null it is assumed that the values are uniformly distributed.
  • If inverseCdf is non-null, the random value is generated using: inverseCdf(nextDouble(), start, end).
  • Note: The function inverseCdf(p, start, end) must return a value in the range [start, end) for each argument p in the range [0,1).

Implementation

/// * If `inverseCdf == null` it is assumed that the values are
///   uniformly distributed.
/// * If `inverseCdf` is non-null, the random value is generated using:
///   `inverseCdf(nextDouble(), start, end)`.
/// * Note: The function `inverseCdf(p, start, end)` must return a
///   value in the range `[start, end)` for each argument `p`
///   in the range `[0,1)`.
num nextInRange(
  num start,
  num end, {
  InverseCdf? inverseCdf,
}) =>
    (inverseCdf == null)
        ? InverseCdfs.uniform(nextDouble(), start, end)
        : inverseCdf(nextDouble(), start, end);