geometricMean method
Returns the geometric mean of this Iterable, or double.nan if the iterable is empty.
For details, see https://en.wikipedia.org/wiki/Geometric_mean.
Example: [2, 8].geometricMean()
returns 4
.
Implementation
double geometricMean() {
var count = 0, sum = 0.0;
for (final value in this) {
count++;
sum += log(value);
}
return count == 0 ? double.nan : exp(sum / count);
}