sampleNormalPdf function

List<num> sampleNormalPdf(
  1. int n,
  2. num mean,
  3. num stdDev,
  4. {num min,
  5. num max,
  6. int seed}
)

Returns a random sample of size n following a normal distribution with parameters:

  • mean,
  • stdDev: standard deviation.

The following parameters are optional:

  • min: minimum value (defaults to mean - 10 * stdDev),
  • max: maximum value (defaults to mean + 10 * stdDev),
  • seed: random generator seed.

Implementation

List<num> sampleNormalPdf(int n, num mean, num stdDev,
    {num? min, num? max, int? seed}) {
  min ??= mean - 10 * stdDev;
  max ??= mean + 10 * stdDev;

  return samplePdf(n, min, max, normalPdf(mean, mean, stdDev),
      (x) => normalPdf(x, mean, stdDev));
}