sample method

  1. @override
int sample({
  1. Random? random,
})
override

Returns a single sample of a random value within the distribution.

Implementation

@override
int sample({Random? random}) {
  const uniform = UniformDistribution.standard();
  var i = 0, b = 1.0;
  while (b >= exp(-lambda)) {
    b *= uniform.sample(random: random);
    i++;
  }
  return i - 1;
}