randomWalk method

List<double> randomWalk(
  1. int steps, {
  2. double start = 0,
  3. double stepSize = 1,
})

Generates a random walk.

Implementation

List<double> randomWalk(int steps, {double start = 0, double stepSize = 1}) {
  final values = <double>[start];
  for (int i = 1; i < steps; i++) {
    final step = normal(0, stepSize);
    values.add(values.last + step);
  }
  return values;
}