cumulativeProbability method

  1. @override
double cumulativeProbability(
  1. int k
)
override

The Cumulative Distribution Function (CDF).

Returns the cumulative probability at x, or the probability of a random variable to be less than or equal to x.

Implementation

@override
// ignore: avoid_renaming_method_parameters
double cumulativeProbability(int k) {
  if (k < lowerBound) {
    return 0;
  } else if (k <= upperBound) {
    var sum = 0.0;
    for (var i = lowerBound; i <= k && i <= upperBound; i++) {
      sum += probability(i);
    }
    return sum;
  } else {
    return 1;
  }
}