quantile property

double get quantile

Current approximate quantile at p (e.g. median when p is 0.5).

Implementation

double get quantile {
  if (_buffer.isEmpty) return double.nan;
  final List<double> sorted = List<double>.of(_buffer)..sort();
  final int i = (_p * (sorted.length - 1)).round().clamp(0, sorted.length - 1);
  return sorted[i];
}