thresholdScott function
Returns the number of bins according to Scott's normal reference rule.
Implementation
// DIVERGES(d3-array): adapt-array-typed-api, typed Iterable<num?> returning
// int and guarding non-finite spreads.
int thresholdScott(Iterable<num?> values, num min, num max) {
final c = count(values);
final d = deviation(values);
if (c > 0 && d != null && d != 0) {
final raw = (max - min) * math.pow(c, 1.0 / 3.0) / (3.49 * d);
if (raw.isFinite) return raw.ceil();
}
return 1;
}