normalCdf function

num normalCdf(
  1. num x,
  2. num mean,
  3. num stdDev
)

Normal cumulative probability density function.

Throws an error of type ErrorOfType<InvalidFunctionParameter> if stdDev < 0.

Implementation

num normalCdf(num x, num mean, num stdDev) {
  if (stdDev <= 0.0) {
    throw throw ErrorOfType<InvalidFunctionParameter>(
      invalidState: 'stdDev: $stdDev <= 0.',
      expectedState: 'stdDev > 0',
    );
  }
  return 0.5 + 0.5 * erf((x - mean) / (math.sqrt2 * stdDev));
}