Mean gets the average of a slice of numbers
(input Float64Data)
| 4 | |
| 5 | // Mean gets the average of a slice of numbers |
| 6 | func Mean(input Float64Data) (float64, error) { |
| 7 | |
| 8 | if input.Len() == 0 { |
| 9 | return math.NaN(), EmptyInputErr |
| 10 | } |
| 11 | |
| 12 | sum, _ := input.Sum() |
| 13 | |
| 14 | return sum / float64(input.Len()), nil |
| 15 | } |
| 16 | |
| 17 | // GeometricMean gets the geometric mean for a slice of numbers |
| 18 | func GeometricMean(input Float64Data) (float64, error) { |
searching dependent graphs…