uniformCdf function

num uniformCdf(
  1. num x,
  2. num min,
  3. num max
)

Uniform cumulative probability density function with non-zero support over the interval (min, max).

Throws an error of type ErrorOfType<InvalidFunctionParameter> if min >= max.

Implementation

num uniformCdf(num x, num min, num max) {
  if (min >= max) {
    throw ErrorOfType<InvalidFunctionParameter>(
      invalidState: 'min: $min >= max: $max',
      expectedState: 'min < max',
    );
  }
  if (x < min) return 0.0;
  if (x > max) return 1.0;
  return (x - min) * uniformPdf(x, min, max);
}