fun add(value: Double) { if (count === 0) { count = 1 mean = value min = value max = value if (!isFinite(value)) { sumOfSquaresOfDeltas = NaN } } else { count++ if (isFinite(value) && isFinite(mean)) { val delta: Double = value - mean mean += delta / count sumOfSquaresOfDeltas += delta * (value - mean) } else { mean = calculateNewMeanNonFinite(mean, value) sumOfSquaresOfDeltas = NaN } min = Math.min(min, value) max = Math.max(max, value) } }
Adds the given value to the dataset .