map<R> method Null safety

Distribution<R> map<R>(
  1. R f(
    1. T value
    )
)

Maps samples of the distribution with the given function.

Example

import 'package:calc/calc.dart';

void main() {
  // Normally distributed dates around 2020-01-01
  final distribution = NormalDistribution(mean=0.0, variance:1.0).map((x) {
    return DateTime(2020, 01, 01).add(Duration(days: x.toInt()));
  });

  // Generate a random DateTime
  final dateTime = distribution.sample();
}

Implementation

Distribution<R> map<R>(R Function(T value) f) {
  return _MappedDistribution<T, R>(this, f);
}