fun mean(vector: DoubleArray): Double { var sum = 0.0 if (vector.size == 0) { return 0 } for (i in vector.indices) { sum += vector[i] } return sum / vector.size.toDouble() }
Computes the mean for an array of doubles .