Question: Disclaimer: No, I didn't find any obvious answer, contrary to what I expected!

When looking for code examples wrt. the arithmetic mean, the first several examples I can turn up via Google seem to be defined such that the empty sequence generates a mean value of `0.0`. (eg. [here](https://rosettacode.org/wiki/Averages/Arithmetic_mean#C.2B.2B) and [here](https://stackoverflow.com/a/1346890/321013) ...)

Looking at Wikipedia however, the [Arithmetic mean](https://en.wikipedia.org/wiki/Arithmetic_mean#Definition) is defined such that an empty sequence would yield `0.0 / 0` -- 

```
 A = 1/n ∑[i=1 -> n](a[i])

```

-- so, possibly, [that is NaN](https://en.wikipedia.org/wiki/NaN#Operations_generating_NaN) in the general case.

So if I write a utility function that calculates the arithmetic mean of a set of floating point values, should I, in the general case:

* return `0.` for the empty sequence?
* return `(Q)NaN` for the empty sequence?
* "throw an exception" in case of empty sequence?

Answer: 
I like defensive coding, so I would throw an exception. You can make it either a specific exception (like empty\_sequence\_exception) or a division by 0, since the divider is the length of the sequence which is 0.

0.0 is debatable since there is no data (sequence).
The correct answer is that the arithmetic mean of an empty sequence has no meaning, since an empty sequence is essentially an empty set. Division of nothing is meaningless. Zero is certainly not a correct answer. Say a sequence has 3 members, 1, 0 and -1, or is a sequence of all zeros. The mean of both of these would be zero, and should not be confused with an empty sequence.