expCdf function

num expCdf(
  1. num x,
  2. num mean
)

Exponential cumulative probability density function with non-zero support over the interval (0, inf).

Throws an exception of type ErrorOfType<InvalidFunctionParameter> if mean <= 0.

Implementation

num expCdf(num x, num mean) {
  if (mean <= 0) {
    throw ErrorOfType<InvalidFunctionParameter>(
      invalidState: 'mean: $mean <= 0.',
      expectedState: 'mean > 0',
    );
  }
  return (x.isNegative) ? 0.0 : 1.0 - math.exp(-x / mean);
}